Hello :wave: The next Gradle version, 9.1, is b...
# configuration-cache
j
Hello πŸ‘‹ The next Gradle version, 9.1, is breaking my plugin with configuration cache. Any hint about what has changed respect to 9.0 related to that? GitHub issue: https://github.com/JavierSegoviaCordoba/semver-gradle-plugin/issues/201
j
That is a bit weird, I am assigning the version in the config phase and I was calling the get(), so it should be invalidated
v
I'd guess it is because you get it from
gradle.startParameter.projectProperties
or if not there manually from
gradle.properties
file or if not there only then through
providers.gradleProperty
.
Maybe there is a bug in the new Gradle optimisation and it should recognize accesses to gradle.startParameter.projectProperties. The
gradle.properties
access probably is tracked already but makes the whole file a configuration cache input.
Maybe - besides reporting the problem - you can mitigate the problem by using a
ValueSource
, because there only the result will be relevant for invalidating CC entries.
If you make clear that it is a regression in 9.1 maybe you are lucky and they fix it before the release
m
Indeed, StartParameter doesn't work great with CC. I'll raise the issue internally.
❀️ 2
j
From top of my head, I think I am doing exactly that, using a chain which includes
StartParameter
m
ValueSource may work, but I need to check first. Why do you need to reimplement the property lookup?
v
From top of my head, I think I am doing exactly that
You do, I looked at your code before writing πŸ™‚
πŸ˜„ 1
Why do you need to reimplement the property lookup?
He considers
gradle.properties
files in project directories between startparameter and the
gradleProperty
provider
Becuase despite its name
gradleProperty
does not deliver Gradle Propertys but Project Propertys and only those that are in the
gradle.properites
file of the root project (and startparameters, env variables, system properties), but not the ones from the project directories.
Whether such non-standard behavior is a good idea is a different topic. πŸ˜„
j
I don’t remember because some years has passed since that, but I think it was the same reason Slack did on their plugin (Foundry). The normal behavior was modified in some Gradle version and it was not picking properties from some
gradle.properties
file if it was not in the root project or in parent projects or in the project itself. Additionally I added support to load
local.properties
I would like a standard method with good defaults to fetch a property from: β€’ terminal β€’ environment variables β€’ .env files β€’ local.properties files β€’ gradle.properties files Chaining those sources if the property is missing with good default priorities.
v
We all want, just Gradle refuses to do so. :-(
j
@Mikhail Lopatkin will
StartParameters
be fixed before the final 9.1 release?
m
will StartParameters be fixed before the final 9.1 release?
Can't promise that right now, but we'll make the decision later today. I'll keep you posted.
πŸ‘ 1
thank you 2
As a workaround, you can use something like
Copy code
abstract class MyValueSource implements ValueSource<String, Params> {
    interface Params extends ValueSourceParameters {
        @Inject
        StartParameter getStartParameter()
    }

    String obtain() {
        parameters.startParameter.projectProperties["foo.bar"]
    }
}


tasks.register("foo") {
    def p = providers.of(MyValueSource) {}
    doLast {
        println(p.getOrNull())
    }
}
πŸ‘€ 1
thank you 1
r
FTR: https://github.com/gradle/gradle/issues/34953 We plan to fix it before 9.1 final
πŸ‘Œ 1
Thanks for the report, @Javi
j
Nice! Thank you πŸ™
@Vampire about
We all want, just Gradle refuses to do so. 😞
Is there an open issue about that, or they have been closed?
v
Closed and rejected
j
Oh, I was following that, I forgot it was rejected 😞