szpak / gradle-pitest-plugin

Gradle plugin for PIT Mutation Testing
http://gradle-pitest-plugin.solidsoft.info/
214 stars 58 forks source link

Multi-Module Plugin Configuration #316

Closed austinarbor closed 2 years ago

austinarbor commented 2 years ago

Is the documentation for a multi-module plugin configuration still accurate? When I try creating a project with that configuration I get a build error. I created a simple project to replicate the issue: https://github.com/austinarbor/pitest-example

When I run any gradle command I get a build error:

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/austinarbor/git/pitest-example/build.gradle' line: 21

* What went wrong:
A problem occurred evaluating root project 'pitest-example'.
> Could not find method pitest() for arguments [build_7tx83dncip5nr5k5thb517upf$_run_closure1$_closure3@21cefca8] on project ':submodule-1' of type org.gradle.api.Project.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org
szpak commented 2 years ago

Thanks @austinarbor for reporting the issue and the sample project. It helped greatly to find a culprit!

TL;TR. See my PR and precisely that commit.

Nevertheless, I have to admit that at first sight it didn't spot the problem. I know that multiproject should work as there is a functional test for similar case which is automatically executed on CI. Today I cloned the project and noticed missing 'java' plugin in the subproject. It is already applied in the submodule configuration, but it seems to be executed after the one from the root build.gradle and the pitest {} configuration block is available only after a 'java' plugin is applied. In general, it would be probably better to configure all related things in one place. Unfortunately, it is missing in the short snippet in README (and there is no link to the functional test). I fixed it.

Btw, in the PR, I added also XML report generation which is required for the aggregated report (which was in the README ;-) ).

austinarbor commented 2 years ago

@szpak thanks for taking a look! I appreciate the help, I would have never though to add the java plugin in the subproject block