Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gradle-plugin] Use registerJavaGeneratingTask #6149

Merged
merged 2 commits into from
Sep 16, 2024

Conversation

martinbonnin
Copy link
Contributor

@martinbonnin martinbonnin commented Sep 16, 2024

Go back to registerJavaGeneratingTask as in 3.x instead of kotlin.srcDir()

Some background:

  1. We initially used kotlin.srcDir() and switched to registerJavaGeneratingTask in 2022 (commit) because it works better with lint (it marks the sources as generated)
  2. But this had 2 drawbacks:
    a. registerJavaGeneratingTask wasn't working from afterEvaluate {}
    b. there was an issue with incremental compilation and tests (issuetracker/268218176)
  3. So we reverted to kotlin.srcDir() (commit)
  4. issuetracker/268218176 has an explanation (we were adding to test variants something that was already accessible)
  5. we don't need afterEvaluate {} anymore because there is no default service anymore
  6. besides the lint issue, kotlin.srcDir() doesn't seem to carry task dependencies for AGP source jar tasks (issuetracker/366293471)
  7. So we're back to 1., with hopefully 2 fixes issues since 2022 (afterEvaluate and test variants)

Also took this opportunity to remove some reflexion that is not needed anymore now that we require Gradle 8.0.

All in all, I wish kotlin.srcDir() would just work as it's more consistent with how generated sources are added in non-Android cases but for the time being, I think we're good with registerJavaGeneratingTask() 🤞

Fixes #6146

@martinbonnin martinbonnin requested a review from BoD as a code owner September 16, 2024 08:56
Copy link

netlify bot commented Sep 16, 2024

Deploy Preview for apollo-android-docs canceled.

Name Link
🔨 Latest commit bcb5c70
🔍 Latest deploy log https://app.netlify.com/sites/apollo-android-docs/deploys/66e7f2c05f24a50008d02458

Copy link
Contributor

@BoD BoD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@BoD BoD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@martinbonnin martinbonnin merged commit f8b28a0 into main Sep 16, 2024
9 checks passed
@martinbonnin martinbonnin deleted the use-register-java-generating-task branch September 16, 2024 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants