gradle-pitest-plugin icon indicating copy to clipboard operation
gradle-pitest-plugin copied to clipboard

pitest version seems to be ignored in build.gradle.kts

Open christophsturm opened this issue 3 years ago • 6 comments

I tried to use the 1.5.2 plugin with the new pitest version (pitestVersion.set("1.6.1")) but looking at the reports it still said "pitest 1.5.2". when running in verbose mode I can see that the 1.5.2 jar files are added to the classpath:

classPathElements=[/Users/christoph/.gradle/caches/modules-2/files-2.1/org.pitest/pitest/1.5.2/9a05e244abe423b3d0e6c9247d50fe02f63f01e0/pitest-1.5.2.jar,....

christophsturm avatar Dec 10 '20 15:12 christophsturm

to reproduce you can use an opensource project of mine, and set pitest version to 1.6.1 here: https://github.com/christophsturm/r2dbcfun/blob/main/build.gradle.kts#L154

christophsturm avatar Dec 10 '20 15:12 christophsturm

Hmm, strange. I have the regression tests for that and they pass. I even extended assertion to verify that pitest-${pitVersion}.jar is displayed during execution and it works. To be sure, I manually checked GPP 1.5.2 with some project with build.gradle in Groovy and requested non-existing PIT version. As expected it failed:

> Could not resolve all files for configuration ':pitest'.
   > Could not find org.pitest:pitest-command-line:1.99.0.

With debugger, I see that your values are not set at all when I bind them to the task (in configureTaskDefault()), however, there are accessible later on, then the task is executed. Unfortunately, to configured plugin dependencies I have to know those values earlier. For some reasons it works fine with Groovy-based configuration.

The options I see:

  • there is "something wrong" with the way you configure the plugin in kts (I don't use Kotlin-based configuration and I don't know what could be wrong)
  • there is "something wrong" with the way I use the extension to resolve PIT dependencies - in the register closure/action (even though it works for Groovy) - can I do it later/more lazy?
  • something else :-)

If you have more extensive Kotlin-based configuration knowledge maybe you can suggest something. Alternatively, maybe you could consult the Gradle forum to get a hint?

szpak avatar Dec 12 '20 21:12 szpak

strange thing is that with the build file from functest it works.

in my own project can put anything into pitestVersion, and when i run gradle dependencies it still shows 1.5.2

christophsturm avatar Dec 17 '20 15:12 christophsturm

I think I found the reason. it only happens with the kotest pitest plugin. probably it has a dependency on pitest and that is stronger than the pitest version that the Gradle plugin creates.

christophsturm avatar Jan 06 '21 13:01 christophsturm

Thanks for digging that topic! That, indeed, might be the reason.

Nevertheless, it's quite interesting as kotest (in master) seems to declare pitest 1.4.11 dependency. 1.5.2 seems to be taken from my plugin - as a default value. Only an ability to override it from the configuration seems to be problematic. Maybe kotest gets that value (version) at the beginning, but I haven't found any evidence in code.

You might want to report it to the kotest developers. Maybe there will have a better idea how to solve your case.

szpak avatar Jan 06 '21 22:01 szpak

I've also had much of the same problem in a non-Kotlin project of mine (can't easily share because it's closed source) that otherwise doesn't have pitest anywhere in the graph.

I managed work around the plugin not picking up the specified version by just mimicking what the code would otherwise be trying to do with it:

project.configurations.pitest.dependencies.add(project.dependencies.create("org.pitest:pitest-command-line:1.9.2"))

https://github.com/szpak/gradle-pitest-plugin/blob/b4028af0a0a5f30a0ad0a79f9f19d8653ccc72af/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy#L222

Rather hacky, but it's getting the job done for the time being if anybody else needed a quick-fix.

EDIT: Not an issue for me anymore with the latest version of the plugin. Presumably it's been fixed by https://github.com/szpak/gradle-pitest-plugin/pull/313

ThomGeG avatar Jul 18 '22 06:07 ThomGeG