szpak / gradle-pitest-plugin

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

Add support for excluding generated classes from mutation based on source path #364

Open jwilmoth-ehs opened 2 months ago

jwilmoth-ehs commented 2 months ago

We have a number of different 3rd party code generation tools (e.g. Mapstruct, DSG) that we do not want to mutate. Because of the different ways code is generated (e.g. annotation processor generated classes depend on src/main/java classes, src/main/java classes depend on types generated from graphql schema files) we're looking for an approach based on source paths being different for generated code vs. handwritten code. The plugin docs state:

To make life easier taskClasspath, mutableCodePaths, sourceDirs, reportDir, verbosity and pitestVersion are automatically set by the plugin. In addition sourceDirs, reportDir, verbosity and pitestVersion can be overridden by a user.

The reportDir and pitestVersion are indeed exposed in the plugin extension, but the sourceDirs property is not.

What is the recommended way to exclude build/generated/** classes from this plugin? Is it intended to be via the sourceDirs property? Some other property (e.g. mutableCodePaths)?

szpak commented 2 months ago

Have you tried with mainSourceSets? You should be able to override the default sourceSets used by the plugin.

https://github.com/szpak/gradle-pitest-plugin/blob/92cc7a8a27007b00034438d9f5fcfc62bd617a03/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy#L191