-
Notifications
You must be signed in to change notification settings - Fork 20
Description
I noticed several issues when trying to use Nebula Info (latest, 14.0.0) with the Gradle configuration cache (latest, 8.14.1):
The primary problem I see is that Nebula Info executes external commands at Gradle configuration time. I think most of these calls are at least wasteful, and in a particular case harmful, and could easily be delayed until Gradle execution time.
Reproduce as follows:
- Create an empty Gradle project.
- Initialize the directory as git with
git init, add an empty remote withgit remote add origin none, add an initial commit, e.g. an empty.gitignore. - Apply "java-library" and Nebula Info in
build.gradle.kts. - Add an empty class at
src/main/java/local/Empty.java. - Execute
./gradlew --no-build-cache --info clean build --configuration-cache - Notice under
> Configure project:the numerous log lines of the form "Starting process command git...". - These log lines happen at configuration time! One would expect them later at execution time, under e.g.
> Task :createPropertiesForJar. - Also note the same call (e.g.
git rev-parse HEAD) is made several times, I'm counting 8, not just once!
My diagnostics attempt:
- Looking at InfoPropertiesFile, we see that
buildNonChangingManifestis invoked as part of the input computation:
https://github.com/nebula-plugins/gradle-info-plugin/blob/main/src/main/groovy/nebula/plugin/info/reporting/InfoPropertiesFile.groovy#L48 - Looking at this line, I suspect
manifestTask.get().propertiesFile.get()causesbuildNonChangingManifestto run at configuration time:
https://github.com/nebula-plugins/gradle-info-plugin/blob/main/src/main/groovy/nebula/plugin/info/reporting/InfoJarPropertiesFilePlugin.groovy#L51 - The call to
buildNonChangingManifest()trickles into things likeGitScmProvider.calculate...andUnknownContinuousIntegration.calculateHost. - So those calculations end up running at configuration time.
Most of these calls are simply wasteful: I believe they should be deferred to execution time, when we actually need to compute the manifest contents, and performed only once each. In all likelihood, it's not worth caching the external Git computation, but still, it should be done only once, at execution time, and only if the manifest is needed.
In one particular case, the early call is actively harmful: On Linux, hostname (and buildUrl) computation trickles via this branch
https://github.com/nebula-plugins/gradle-info-plugin/blob/main/src/main/groovy/nebula/plugin/info/ci/AbstractContinuousIntegrationProvider.groovy#L48
into a Jna call
https://github.com/nebula-plugins/gradle-info-plugin/blob/main/src/main/groovy/nebula/plugin/info/ci/POSIXUtil.groovy#L23
This Jna call done at configuration time is outright incompatible with the Gradle configuration cache.