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

Remove usage of System.getProperties() during Gradle configuration phase #106

Open
MikhailShamaev-TomTom opened this issue Feb 20, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@MikhailShamaev-TomTom
Copy link

Describe the bug

JFrog plugin calls BuildInfoExtractorUtils.mergePropertiesWithSystemAndPropertyFile, which in turn calls props.putAll(System.getProperties()); at Gradle configuration phase when configuration caching is enabled.

This makes every system property a configuration cache input, so if any property changes and the rest of the configuration does not read this value, configuration cache entry will be invalidated anyway.

For example, in certain cases Gradle sets idea.io.use.nio2 property, nothing in the configuration phase reads this value except 'com.jfrog.artifactory' plugin and that means if that property changes, configuration cache is invalidated.

Unfortunately Gradle does change the property idea.io.use.nio2 every time it re-compiles build.gradle.kts, which means that configuration cache is not usable for a second run.

Current behavior

Clip of configuration cache report:
image

On first run

$ ./gradlew tasks --configuration-cache
Calculating task graph as configuration cache cannot be reused because file 'build.gradle.kts' has changed.
..

On second run

$ ./gradlew tasks --configuration-cache
Calculating task graph as configuration cache cannot be reused because system property 'idea.io.use.nio2' has changed.
..

Reproduction steps

In a project with jfrog artifactory plugin configured:

  • Modify build.gradle.kts to force Gradle to recompile it.
  • Run ./gradlew tasks --configuration-cache twice.
    • First run ends with Configuration cache entry stored. output from Gradle.

Expected behavior

Second run of Gradle command, the Configuration cache entry reused. output is expected.

Artifactory Gradle plugin version

5.2.0

Operating system type and version

Ubuntu 22

JFrog Artifactory version

No response

Gradle version

8.6

@MikhailShamaev-TomTom MikhailShamaev-TomTom added the bug Something isn't working label Feb 20, 2024
@deeptisjfrog
Copy link

As per customer ,
The evaluation of system properties should be moved from the Gradle configuration phase to the execution phase. This can be accomplished in Gradle if you use a Provider<> and pass it to tasks inputs, instead of evaluating it in the configuration phase by calling Provider.get(). In this case, Gradle will not record that all system properties were an input for the configuration phase.
You may consider reading only the properties that you are interested in, not all of them. In this case, only those properties will be treated as an input. By doing so, the issue will be also solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants