Hi everyone!
I noticed that the current documentation for setting up the mockitoAgent with Gradle will not work when you enable the configuration cache (e.g. by adding org.gradle.configuration-cache=true to your gradle.properties).
I get the following error message:
Calculating task graph as no cached configuration is available for tasks: clean spotlessApply build
> Task :test FAILED
1 problem was found storing the configuration cache.
- Task `:test` of type `org.gradle.api.tasks.testing.Test`: invocation of 'configurations' references a Gradle script object from a Groovy closure at execution time, which is unsupported with the configuration cache.
See https://docs.gradle.org/9.5.1/userguide/configuration_cache_requirements.html#config_cache:requirements:gradle_model_types
However, this approach seems to work:
configurations {
mockitoAgent
}
test {
useJUnitPlatform()
jvmArgumentProviders.add(new CommandLineArgumentProvider() {
@InputFiles
@PathSensitive(PathSensitivity.RELATIVE)
FileCollection mockitoAgent = configurations.mockitoAgent
@Override
Iterable<String> asArguments() {
["-javaagent:${mockitoAgent.asPath}", "-XX:+EnableDynamicAgentLoading"]
}
})
}
Since I'm not the greatest expert in Gradle, I wanted to share my solution. Maybe this approach can be improved? Maybe you want to use it to improve the Javadoc documentation?
I use Gradle 9.5.1 + Mockito 5.23.0
Thanks!
Christopher
Hi everyone!
I noticed that the current documentation for setting up the
mockitoAgentwith Gradle will not work when you enable the configuration cache (e.g. by addingorg.gradle.configuration-cache=trueto yourgradle.properties).I get the following error message:
However, this approach seems to work:
Since I'm not the greatest expert in Gradle, I wanted to share my solution. Maybe this approach can be improved? Maybe you want to use it to improve the Javadoc documentation?
I use Gradle 9.5.1 + Mockito 5.23.0
Thanks!
Christopher