Skip to content

Gradle init script improvements #264

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

Merged
merged 23 commits into from
Mar 7, 2023
Merged

Conversation

erichaagdev
Copy link
Member

@erichaagdev erichaagdev commented Dec 29, 2022

❄️ Winter Update PR Navigator ❄️

  1. Include realized build time savings in experiment summary #261
  2. Include performance characteristics and support -x for Gradle experiment 1  #262
  3. Always read project name from Build Scan data #263
  4. Gradle init script improvements #264
  5. Adopt Foojay Toolchains and Kotlin DSL plugins in build logic #265
  6. Add variable to query debug mode #266
  7. Modernize Java launch code #267
  8. Display serialization factor in summary of all experiments #272
  9. Display potential build time savings in experiment summaries #274
  10. Update the contract of command line tools #283

⛄ = you are here

Summary

This PR is a rebased version of #121 from @bigdaz. I decided to create a new branch and PR in order to preserve his branch as it. That way I could easily switch between the two as I verified these changes. Once this PR is merged #121 can be closed.

⚠️ While testing these changes, I discovered a bug that exists in the #121 version when running with Gradle 5.x. When running the scripts with -e both com.gradle.build-scan and com.gradle.enterprise are applied. This can be seen in this Build Scan. It seems this scenario causes an error when applying CCUD.

I was able to resolve this by removing --scan as a parameter to the build validation scripts' Gradle invocation. Since the initialization scripts take care of configuring and setting up Gradle Enterprise I don't think the --scan parameter is required.

However, --scan is still displayed in the printed Gradle invocation command. This is somewhat misleading now. In my opinion, it was also misleading before since the displayed command does not include the initialization scripts that perform additional configuration transparent to the user.

The only other change from #121 is that I removed all logger calls in the initialization scripts since they created unnecessary noise in the validation scripts output that was not present before.

Testing

In order to test this I ran the following experiments and verified a successful outcome.

The following parameter combinations were tested with Gradle 5.x, 6.x, and 7.x:

  • online
  • offline (-x)
  • online, enable GE (-e)
  • offline (-x), enable GE (-e)
./03-validate-local-build-caching-different-locations.sh -r git@github.com:gradle/ge-solutions.git -p sample-projects/gradle/5.x/ge -t 'build'
./03-validate-local-build-caching-different-locations.sh -r git@github.com:gradle/ge-solutions.git -p sample-projects/gradle/5.x/ge -t 'build' -x
./03-validate-local-build-caching-different-locations.sh -r git@github.com:gradle/ge-solutions.git -p sample-projects/gradle/5.x/no-ge -t 'build' -e -s https://ge.solutions-team.gradle.com
./03-validate-local-build-caching-different-locations.sh -r git@github.com:gradle/ge-solutions.git -p sample-projects/gradle/5.x/no-ge -t 'build' -e -x
./03-validate-local-build-caching-different-locations.sh -r git@github.com:gradle/ge-solutions.git -p sample-projects/gradle/6.x/ge -t 'build'
./03-validate-local-build-caching-different-locations.sh -r git@github.com:gradle/ge-solutions.git -p sample-projects/gradle/6.x/ge -t 'build' -x
./03-validate-local-build-caching-different-locations.sh -r git@github.com:gradle/ge-solutions.git -p sample-projects/gradle/6.x/no-ge -t 'build' -e -s https://ge.solutions-team.gradle.com
./03-validate-local-build-caching-different-locations.sh -r git@github.com:gradle/ge-solutions.git -p sample-projects/gradle/6.x/no-ge -t 'build' -e -x
./03-validate-local-build-caching-different-locations.sh -r git@github.com:gradle/ge-solutions.git -p sample-projects/gradle/7.x/ge -t 'build'
./03-validate-local-build-caching-different-locations.sh -r git@github.com:gradle/ge-solutions.git -p sample-projects/gradle/7.x/ge -t 'build' -x
./03-validate-local-build-caching-different-locations.sh -r git@github.com:gradle/ge-solutions.git -p sample-projects/gradle/7.x/no-ge -t 'build' -e -s https://ge.solutions-team.gradle.com
./03-validate-local-build-caching-different-locations.sh -r git@github.com:gradle/ge-solutions.git -p sample-projects/gradle/7.x/no-ge -t 'build' -e -x
./04-validate-remote-build-caching-ci-ci.sh -1 https://ge.solutions-team.gradle.com/s/fvwne3ht4xgjg -2 https://ge.solutions-team.gradle.com/s/tjiwbi2b7oioo
./05-validate-remote-build-caching-ci-local.sh -1 https://ge.solutions-team.gradle.com/s/lc73bw56kdkxi

@jthurne
Copy link
Member

jthurne commented Jan 7, 2023

However, --scan is still displayed in the printed Gradle invocation command. This is somewhat misleading now. In my opinion, it was also misleading before since the displayed command does not include the initialization scripts that perform additional configuration transparent to the user.

The intent with the displayed command is to show the user a simple command they can use themselves when running Gradle directly to achieve a similar result. With that in mind, we don't print out the full command used so as not to distract or misslead the user.

These initialization scripts have become sufficiently complex that I think many users would have difficulty interpreting them or understanding what they do. Which is fine, but it's a reason why we don't necessarily want to display their use in the command that we execute.

@jthurne
Copy link
Member

jthurne commented Jan 7, 2023

Once this PR is merged #121 can be closed.

Would it be okay if we closed it now? I've gotten confused a few times between #121 and this PR. Closing a PR doesn't delete the underlying branch, so you could still compare your branch against Daz's original branch.

@erichaagdev
Copy link
Member Author

A positive side effect of removing --scan is that if a build is not actually configured with Gradle Enterprise, then it will not try to publish a Build Scan to scans.gradle.com. For example:

./03-validate-local-build-caching-different-locations.sh -r https://github.com/android/nowinandroid -t assembleDemoDebug

If we run the above without these changes, the build will fail with the following error:

image

As you can see, it is asking to accept the terms of service so that a Build Scan may be published to scans.gradle.com. This is risky when running the scripts for a project whose Build Scan should not be made publicly available. With these changes, the user will see the following instead:

image

@runningcode runningcode removed their request for review March 1, 2023 09:08
@erichaagdev erichaagdev force-pushed the erichaagdev/always-read-project-name-from-build-scan branch from f3bab9a to c912797 Compare March 6, 2023 00:08
bigdaz added 8 commits March 5, 2023 19:11
Loading the GE plugin into the initscript classpath is not required.
Removes the separate 'capture-published-build-scan.gradle' init script, merging the
functionality into 'configure-gradle-enterprise.gradle'. This reduces duplication and
simplifies the overall scripts.
Borrowing the logic from the TC Build Scan plugin, the init-script now
checks if the GE / CCUD plugins are already applied.
This reduces duplication and increases similarity with TC Build Scan plugin.
erichaagdev and others added 5 commits March 5, 2023 19:12
@erichaagdev erichaagdev force-pushed the erichaagdev/init-script-cleanup branch from ae59a4b to 7e0594d Compare March 6, 2023 00:16
Base automatically changed from erichaagdev/always-read-project-name-from-build-scan to main March 6, 2023 16:26
@erichaagdev erichaagdev merged commit c6d6970 into main Mar 7, 2023
@erichaagdev erichaagdev deleted the erichaagdev/init-script-cleanup branch March 7, 2023 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants