Skip to content

Improve compatibility with the Gradle configuration cache #109

@mateidavid

Description

@mateidavid

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 with git 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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions