From e9f6691457e5aeadac15373ae0b3e12ec393dd93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Sat, 12 Mar 2022 19:08:00 +0100 Subject: [PATCH 01/60] Upgrade Gradle to 6.9.2 --- CHANGELOG.md | 4 ++++ gradle/wrapper/gradle-wrapper.properties | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa984235..929aaeca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # gradle-pitest-plugin changelog +## 1.7.1 - Unreleased + + - Upgrade Gradle wrapper to 6.9.2 + ## 1.7.0 - 2021-09-20 - Support for Gradle configuration cache - [#249](https://github.com/szpak/gradle-pitest-plugin/issues/249) - PR by [David Burstrom](https://github.com/davidburstrom) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 101011dd..a38e081b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha256Sum=b13f5d97f08000996bf12d9dd70af3f2c6b694c2c663ab1b545e9695562ad1ee -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-all.zip +distributionSha256Sum=8bde5c859a3ddf5d127ac77465fc24fa8a831d3d8d49e8248548f2cb87485ef1 +distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 5d3c8dc19eaae62118dabf2db79cfcc45f2bcee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Sat, 12 Mar 2022 19:15:02 +0100 Subject: [PATCH 02/60] PIT 1.7.4 by default --- CHANGELOG.md | 1 + build.gradle | 2 +- .../groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 929aaeca..708867ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 1.7.1 - Unreleased + - PIT 1.7.4 by default - Upgrade Gradle wrapper to 6.9.2 ## 1.7.0 - 2021-09-20 diff --git a/build.gradle b/build.gradle index a7a26174..ecf13ef1 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ buildscript { sourceCompatibility = 1.8 -ext.pitestAggregatorVersion = "1.7.0" //Must be equal to default PIT version in PitestPlugin +ext.pitestAggregatorVersion = "1.7.4" //Must be equal to default PIT version in PitestPlugin repositories { mavenCentral() diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index 0e5e53d3..8fabbdc0 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -52,7 +52,7 @@ class PitestPlugin implements Plugin { public final static String PITEST_REPORT_DIRECTORY_NAME = 'pitest' public final static String PITEST_CONFIGURATION_NAME = 'pitest' - public final static String DEFAULT_PITEST_VERSION = '1.7.0' + public final static String DEFAULT_PITEST_VERSION = '1.7.4' @Internal //6.4 due to main -> mainClass change to avoid deprecation warning in Gradle 7.x - https://github.com/szpak/gradle-pitest-plugin/pull/289 public static final GradleVersion MINIMAL_SUPPORTED_GRADLE_VERSION = GradleVersion.version("6.4") //public as used also in regression tests From 4427d7c235389bd6518a40664233aa06f35b91d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Sat, 12 Mar 2022 20:31:09 +0100 Subject: [PATCH 03/60] CHANGELOG update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 708867ea..5992e6b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - PIT 1.7.4 by default - Upgrade Gradle wrapper to 6.9.2 + - Test for exclusion of certain mutators - [#303](https://github.com/szpak/gradle-pitest-plugin/pull/303) - PR by [Narendra Pathai](https://github.com/npathai) ## 1.7.0 - 2021-09-20 From 0ad82e9e7341efb1f341aa55ea91d64203947b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Sat, 12 Mar 2022 21:13:08 +0100 Subject: [PATCH 04/60] [#277] Handle testPlugin deprecation It is not passed to PIT 1.6.7+ for forward compatibility (as it is planned to be removed in PIT 1.8.0). Fixed #277. --- CHANGELOG.md | 8 ++- README.md | 8 +-- .../functional/Junit5FunctionalSpec.groovy | 2 - ...stPluginGradleVersionFunctionalSpec.groovy | 4 +- .../testProjects/junit5kotlin/build.gradle | 2 +- .../testProjects/junit5simple/build.gradle | 1 - .../testProjects/junit5spock2/build.gradle | 1 - .../gradle/pitest/PitestPlugin.groovy | 16 +++++ .../pitest/PitestPluginExtension.groovy | 7 ++- .../pitest/PitestTaskConfigurationSpec.groovy | 5 +- ...testTaskTestPluginConfigurationSpec.groovy | 62 +++++++++++++++++++ 11 files changed, 99 insertions(+), 17 deletions(-) create mode 100644 src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskTestPluginConfigurationSpec.groovy diff --git a/CHANGELOG.md b/CHANGELOG.md index 5992e6b7..0755a648 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,17 @@ # gradle-pitest-plugin changelog -## 1.7.1 - Unreleased +## 1.7.4 - Unreleased + - Do not pass `--testPlugin` for PIT 1.6.7+ for forward compatibility - [#277](https://github.com/szpak/gradle-pitest-plugin/issues/277) + - Deprecate `testPlugin` configuration parameter (not needed in [PIT 1.6.7+](https://github.com/hcoles/pitest/pull/900), to be removed in PIT 1.8.0) - [#277](https://github.com/szpak/gradle-pitest-plugin/issues/277) - PIT 1.7.4 by default - Upgrade Gradle wrapper to 6.9.2 - Test for exclusion of certain mutators - [#303](https://github.com/szpak/gradle-pitest-plugin/pull/303) - PR by [Narendra Pathai](https://github.com/npathai) +**Compatibility notes**: +1. The `testPlugin` configuration parameter is deprecated and should not be used. In fact, starting with 1.6.7 it is no longer used (it is enough to add the PIT plugin as a buildscript dependency or just set `junit5PluginVersion` to use the JUnit 5 plugin). In addition, that property is planned to be removed in PIT 1.8.0. + + ## 1.7.0 - 2021-09-20 - Support for Gradle configuration cache - [#249](https://github.com/szpak/gradle-pitest-plugin/issues/249) - PR by [David Burstrom](https://github.com/davidburstrom) diff --git a/README.md b/README.md index 9b3e4fcc..cf16d5e8 100644 --- a/README.md +++ b/README.md @@ -271,7 +271,7 @@ For mixing JUnit 5 with other PIT plugins, you can read [this section](https://b ### Generic plugin support (also JUnit 5 in gradle-pitest-plugin <1.4.7) -To enable PIT plugins, it is enough to add it to the pitest configuration in the buildscript closure and also set the `testPlugin` property. For example: +To enable PIT plugins, it is enough to add it to the pitest configuration in the buildscript closure. For example: ```groovy plugins { @@ -286,16 +286,12 @@ repositories { dependencies { pitest 'org.example.pit.plugins:pitest-custom-plugin:0.42' } - -pitest { - testPlugin = 'custom' //or built-in 'testng' which also has to be activated - // ... -} ``` The minimal working example is available in the [functional tests suite](https://github.com/szpak/gradle-pitest-plugin/blob/master/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginFunctional1Spec.groovy#L69-91). Please note. In gradle-pitest-plugin <1.5.0 the `pitest` configuration had to be created in the `buildscript` scope for the root project. +Please note. Starting with PIT 1.6.7 it is no longer needed to set `testPlugin` configuration parameter. It is also deprecated in the Gradle plugin. ## Versions diff --git a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy index 0f9fecda..b88e07ae 100644 --- a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy +++ b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy @@ -42,7 +42,6 @@ class Junit5FunctionalSpec extends AbstractPitestFunctionalSpec { !result.failure result.wasExecuted('pitest') and: - result.standardOutput.contains('--testPlugin=junit5') result.standardOutput.contains('Generated 1 mutations Killed 1 (100%)') and: result.standardOutput.contains("pitest-junit5-plugin-${expectedJunitPluginVersion}.jar") @@ -66,7 +65,6 @@ class Junit5FunctionalSpec extends AbstractPitestFunctionalSpec { !result.failure result.wasExecuted('pitest') and: - result.standardOutput.contains('--testPlugin=junit5') result.standardOutput.contains('Generated 1 mutations Killed 1 (100%)') } diff --git a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy index 9ce77c7c..c3628ce7 100644 --- a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy +++ b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy @@ -31,7 +31,7 @@ import static info.solidsoft.gradle.pitest.PitestTaskConfigurationSpec.PIT_PARAM @CompileDynamic class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSpec { - private static final GradleVersion LATEST_KNOWN_GRADLE_VERSION = GradleVersion.version("7.2") + private static final GradleVersion LATEST_KNOWN_GRADLE_VERSION = GradleVersion.version("7.4.1") //Baased on https://docs.gradle.org/current/userguide/compatibility.html private static final Map MINIMAL_GRADLE_VERSION_FOR_JAVA_VERSION = [ @@ -102,7 +102,7 @@ class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSp private static final String REGRESSION_TESTS_ENV_NAME = "PITEST_REGRESSION_TESTS" private static final List GRADLE6_VERSIONS = ["6.9.1", "6.8.3", "6.7", "6.6", "6.5", PitestPlugin.MINIMAL_SUPPORTED_GRADLE_VERSION.version] - private static final List GRADLE7_VERSIONS = ["7.2", "7.1.1", "7.0.2"] + private static final List GRADLE7_VERSIONS = [LATEST_KNOWN_GRADLE_VERSION.version, "7.3.3", "7.2", "7.1.1", "7.0.2"] private static final List GRADLE_LATEST_VERSIONS = [GRADLE6_VERSIONS.first(), GRADLE7_VERSIONS.first(), PitestPlugin.MINIMAL_SUPPORTED_GRADLE_VERSION.version] diff --git a/src/funcTest/resources/testProjects/junit5kotlin/build.gradle b/src/funcTest/resources/testProjects/junit5kotlin/build.gradle index 7ec2266a..56f21b6b 100644 --- a/src/funcTest/resources/testProjects/junit5kotlin/build.gradle +++ b/src/funcTest/resources/testProjects/junit5kotlin/build.gradle @@ -42,7 +42,7 @@ compileTestKotlin { } pitest { - testPlugin = "junit5" +// testPlugin = "junit5" //no longer needed with PIT 1.6.7+ avoidCallsTo = ["kotlin.jvm.internal"] mutators = ["STRONGER"] targetClasses = ['pitest.test.*'] //by default "${project.group}.*" diff --git a/src/funcTest/resources/testProjects/junit5simple/build.gradle b/src/funcTest/resources/testProjects/junit5simple/build.gradle index 28f68875..2a04bdc4 100644 --- a/src/funcTest/resources/testProjects/junit5simple/build.gradle +++ b/src/funcTest/resources/testProjects/junit5simple/build.gradle @@ -34,6 +34,5 @@ test { } pitest { -// testPlugin = "junit5" //not needed - 'junit5PluginVersion' should implicitly set it junit5PluginVersion = "0.15" } diff --git a/src/funcTest/resources/testProjects/junit5spock2/build.gradle b/src/funcTest/resources/testProjects/junit5spock2/build.gradle index d76c7ee7..b45334c9 100644 --- a/src/funcTest/resources/testProjects/junit5spock2/build.gradle +++ b/src/funcTest/resources/testProjects/junit5spock2/build.gradle @@ -30,6 +30,5 @@ test { } pitest { -// testPlugin = "junit5" //not needed - 'junit5PluginVersion' should implicitly set it junit5PluginVersion = "0.14" } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index 8fabbdc0..4a2b77e0 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -90,6 +90,7 @@ class PitestPlugin implements Plugin { t.dependsOn(calculateTasksToDependOn()) t.shouldRunAfter(project.tasks.named(TEST_TASK_NAME)) addPitDependencies(pitestConfiguration) + suppressPassingDeprecatedTestPluginForNewerPitVersions(t) } } } @@ -246,4 +247,19 @@ class PitestPlugin implements Plugin { } } + private void suppressPassingDeprecatedTestPluginForNewerPitVersions(PitestTask pitestTask) { + String configuredPitVersion = extension.pitestVersion.get() + try { + final GradleVersion minimalPitVersionNotNeedingTestPluginProperty = GradleVersion.version("1.6.7") + if (GradleVersion.version(configuredPitVersion) >= minimalPitVersionNotNeedingTestPluginProperty) { + log.info("Passing '--testPlugin' to PIT disabled for PIT 1.6.7+. See https://github.com/szpak/gradle-pitest-plugin/issues/277") + pitestTask.testPlugin.set((String)null) + } + } catch (IllegalArgumentException e) { + log.warn("Error during PIT versions comparison. Is '$configuredPitVersion' really valid? If yes, please report this incident. " + + "Assuming PIT version is newer than 1.6.7.") + log.warn("Original exception: ${e.class.name}:${e.message}") + } + } + } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy index ca34b79a..e6e8dd04 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy @@ -42,12 +42,17 @@ class PitestPluginExtension { /** * Specifies what test plugin to use. * - * Prior to 1.3.0 this was autodetected, now it has to be specified. The junit plugin is used by default. + * Prior to 1.3.0 this was auto detected. Up to 1.6.8 it has to be specified. With 1.6.7+ is not needed anymore (test plugins are auto detected) + * and it is deprecated in PIT. To be removed in 1.8.0. * * For using with JUnit 5 please see: junit5PluginVersion * + * Related issue: https://github.com/szpak/gradle-pitest-plugin/issues/277 + * * @since 1.3.0 + * @deprecated Not needed with PIT 1.6.7+, to be removed in PIT 1.8.0. */ + @Deprecated final Property testPlugin /** diff --git a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy index 42dc9079..4d96de7d 100644 --- a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy +++ b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy @@ -18,6 +18,8 @@ package info.solidsoft.gradle.pitest import groovy.transform.CompileDynamic import spock.lang.Issue +//TODO: Think if task initialization with WithPitestTaskInitialization is not performed to early +// (see PitestTaskTestPluginConfigurationSpec for corner case with login in PitestPlugin) @CompileDynamic class PitestTaskConfigurationSpec extends BasicProjectBuilderSpec implements WithPitestTaskInitialization { @@ -127,8 +129,7 @@ class PitestTaskConfigurationSpec extends BasicProjectBuilderSpec implements Wit where: //pitConfigParamName value taken from gradleConfigParamName if set to null configParamName | gradleConfigValue || expectedPitConfigValue - "testPlugin" | "testng" || "testng" - //junit5PluginVersion tested separately + //testPlugin and junit5PluginVersion tested separately "reportDir" | new File("//tmp//foo") || new File("//tmp//foo").path //due to issues on Windows "targetClasses" | ["a", "b"] || "a,b" "targetTests" | ["t1", "t2"] || "t1,t2" diff --git a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskTestPluginConfigurationSpec.groovy b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskTestPluginConfigurationSpec.groovy new file mode 100644 index 00000000..b5394c7d --- /dev/null +++ b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskTestPluginConfigurationSpec.groovy @@ -0,0 +1,62 @@ +package info.solidsoft.gradle.pitest + +import groovy.transform.CompileDynamic +import spock.lang.Issue + +@CompileDynamic +@Issue("https://github.com/szpak/gradle-pitest-plugin/issues/277") +class PitestTaskTestPluginConfigurationSpec extends BasicProjectBuilderSpec { + + void "should not pass testPlugin for PIT 1.6.7+ (#pitVersion, #testPlugin, #junit5PluginVersion)"() { + given: + project.pitest.pitestVersion = pitVersion + project.pitest.testPlugin = testPlugin + project.pitest.junit5PluginVersion = junit5PluginVersion + and: + PitestTask task = getJustOnePitestTaskOrFail() //TODO: Think if task initialization in PitestTaskConfigurationSpec is done in right place + expect: + task.taskArgumentMap()['testPlugin'] == null + where: + pitVersion | testPlugin | junit5PluginVersion + "1.6.7" | "junit5" | null + "1.6.8-SNAPSHOT" | "junit5" | null + "1.7.0" | "junit5" | null + "2.0.0" | "junit5" | null + "2.0" | "junit5" | null + "1.6.7" | null | "0.23" + "1.6.8-SNAPSHOT" | null | "0.23" + "1.7.0" | null | "0.23" + "2.0.0" | null | "0.23" + "2.0" | null | "0.23" + } + + void "should pass testPlugin for backward compatibility for PIT <1.6.7 (#pitVersion, #testPlugin, #junit5PluginVersion)"() { + given: + project.pitest.pitestVersion = pitVersion + project.pitest.testPlugin = testPlugin + project.pitest.junit5PluginVersion = junit5PluginVersion + and: + PitestTask task = getJustOnePitestTaskOrFail() + expect: + task.taskArgumentMap()['testPlugin'] == "junit5" + where: + pitVersion | testPlugin | junit5PluginVersion + "1.0.0" | "junit5" | null + "1.6.6" | "junit5" | null + "1.6.6-SNAPSHOT" | "junit5" | null + "1.0.0" | null | "0.23" + "1.6.6" | null | "0.23" + "1.6.6-SNAPSHOT" | null | "0.23" + } + + void "should not fail for unrecognised PIT version and assume newer one"() { + given: + project.pitest.pitestVersion = "incorrect-version" + project.pitest.testPlugin = "testng" + and: + PitestTask task = getJustOnePitestTaskOrFail() + expect: + task.taskArgumentMap()['testPlugin'] == "testng" + } + +} From cd71c21ca64643ba1d78c7131dac6beb8a44332f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Sat, 12 Mar 2022 21:19:22 +0100 Subject: [PATCH 05/60] Remove hack for Gradle <6.0 compatibility --- .../info/solidsoft/gradle/pitest/PitestPlugin.groovy | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index 4a2b77e0..7d7af147 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -182,12 +182,12 @@ class PitestPlugin implements Plugin { return filteredCombinedTaskClasspath } as Callable) task.useAdditionalClasspathFile.set(extension.useClasspathFile) - //additionalClasspathFile - separate method + task.additionalClasspathFile.set(new File(project.buildDir, PIT_ADDITIONAL_CLASSPATH_DEFAULT_FILE_NAME)) task.mutableCodePaths.setFrom(allMutableCodePaths) task.historyInputLocation.set(extension.historyInputLocation) task.historyOutputLocation.set(extension.historyOutputLocation) task.enableDefaultIncrementalAnalysis.set(extension.enableDefaultIncrementalAnalysis) - //defaultFileForHistoryData - separate method + task.defaultFileForHistoryData.set(new File(project.buildDir, PIT_HISTORY_DEFAULT_FILE_NAME)) task.mutationThreshold.set(extension.mutationThreshold) task.coverageThreshold.set(extension.coverageThreshold) task.testStrengthThreshold.set(extension.testStrengthThreshold) @@ -202,14 +202,6 @@ class PitestPlugin implements Plugin { task.maxSurviving.set(extension.maxSurviving) task.useClasspathJar.set(extension.useClasspathJar) task.features.set(extension.features) - - configurePropertiesWithProblematicTypesForGradle5(task) - } - - @CompileDynamic //To keep Gradle <6.0 compatibility - see https://github.com/gradle/gradle/issues/10953 - private void configurePropertiesWithProblematicTypesForGradle5(PitestTask task) { - task.additionalClasspathFile.set(new File(project.buildDir, PIT_ADDITIONAL_CLASSPATH_DEFAULT_FILE_NAME)) - task.defaultFileForHistoryData.set(new File(project.buildDir, PIT_HISTORY_DEFAULT_FILE_NAME)) } private Set calculateBaseMutableCodePaths() { From 117d5a8ed5a451fb651f6e9b3586f05f31b7e059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Sat, 12 Mar 2022 21:40:35 +0100 Subject: [PATCH 06/60] [#277] Do not set testPlugins for junit5PluginVersion For forward compatibility with planned PIT 1.8.0. --- CHANGELOG.md | 1 + .../gradle/pitest/PitestPlugin.groovy | 29 +++++++++---------- ...testTaskTestPluginConfigurationSpec.groovy | 20 +++++++++++-- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0755a648..c3c34725 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ **Compatibility notes**: 1. The `testPlugin` configuration parameter is deprecated and should not be used. In fact, starting with 1.6.7 it is no longer used (it is enough to add the PIT plugin as a buildscript dependency or just set `junit5PluginVersion` to use the JUnit 5 plugin). In addition, that property is planned to be removed in PIT 1.8.0. +2. Using `junit5PluginVersion` no longer internally set `testPlugin` property. For using with old PIT (<1.6.7) it is required to set it explicitly in configuration. ## 1.7.0 - 2021-09-20 diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index 7d7af147..6a0e5849 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -225,32 +225,31 @@ class PitestPlugin implements Plugin { private void addPitJUnit5PluginIfRequested(Configuration pitestConfiguration) { if (extension.junit5PluginVersion.isPresent()) { - if (!extension.testPlugin.isPresent()) { - log.info("Implicitly using JUnit 5 plugin for PIT with version defined in 'junit5PluginVersion'") - extension.testPlugin.set(PITEST_JUNIT5_PLUGIN_NAME) - } if (extension.testPlugin.isPresent() && extension.testPlugin.get() != PITEST_JUNIT5_PLUGIN_NAME) { log.warn("Specified 'junit5PluginVersion', but other plugin is configured in 'testPlugin' for PIT: '${extension.testPlugin.get()}'") } String junit5PluginDependencyAsString = "org.pitest:pitest-junit5-plugin:${extension.junit5PluginVersion.get()}" - log.info("Adding dependency: ${junit5PluginDependencyAsString}") + log.info("Adding JUnit 5 plugin for PIT as dependency: ${junit5PluginDependencyAsString}") pitestConfiguration.dependencies.add(project.dependencies.create(junit5PluginDependencyAsString)) } } private void suppressPassingDeprecatedTestPluginForNewerPitVersions(PitestTask pitestTask) { - String configuredPitVersion = extension.pitestVersion.get() - try { - final GradleVersion minimalPitVersionNotNeedingTestPluginProperty = GradleVersion.version("1.6.7") - if (GradleVersion.version(configuredPitVersion) >= minimalPitVersionNotNeedingTestPluginProperty) { - log.info("Passing '--testPlugin' to PIT disabled for PIT 1.6.7+. See https://github.com/szpak/gradle-pitest-plugin/issues/277") - pitestTask.testPlugin.set((String)null) + if (extension.testPlugin.isPresent()) { + log.warn("DEPRECATION WARNING. `testPlugin` is deprecated starting with GPP 1.7.4. It is also not used starting with PIT 1.6.7 (to be removed in 1.8.0).") + String configuredPitVersion = extension.pitestVersion.get() + try { + final GradleVersion minimalPitVersionNotNeedingTestPluginProperty = GradleVersion.version("1.6.7") + if (GradleVersion.version(configuredPitVersion) >= minimalPitVersionNotNeedingTestPluginProperty) { + log.info("Passing '--testPlugin' to PIT disabled for PIT 1.6.7+. See https://github.com/szpak/gradle-pitest-plugin/issues/277") + pitestTask.testPlugin.set((String)null) + } + } catch (IllegalArgumentException e) { + log.warn("Error during PIT versions comparison. Is '$configuredPitVersion' really valid? If yes, please report that case. " + + "Assuming PIT version is newer than 1.6.7.") + log.warn("Original exception: ${e.class.name}:${e.message}") } - } catch (IllegalArgumentException e) { - log.warn("Error during PIT versions comparison. Is '$configuredPitVersion' really valid? If yes, please report this incident. " + - "Assuming PIT version is newer than 1.6.7.") - log.warn("Original exception: ${e.class.name}:${e.message}") } } diff --git a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskTestPluginConfigurationSpec.groovy b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskTestPluginConfigurationSpec.groovy index b5394c7d..696e467e 100644 --- a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskTestPluginConfigurationSpec.groovy +++ b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskTestPluginConfigurationSpec.groovy @@ -44,9 +44,23 @@ class PitestTaskTestPluginConfigurationSpec extends BasicProjectBuilderSpec { "1.0.0" | "junit5" | null "1.6.6" | "junit5" | null "1.6.6-SNAPSHOT" | "junit5" | null - "1.0.0" | null | "0.23" - "1.6.6" | null | "0.23" - "1.6.6-SNAPSHOT" | null | "0.23" + "1.0.0" | "junit5" | "0.23" + "1.6.6" | "junit5" | "0.23" + "1.6.6-SNAPSHOT" | "junit5" | "0.23" + } + + void "should automatically set testPlugin if junit5PluginVersion is used for any version"() { + given: + project.pitest.pitestVersion = pitVersion + project.pitest.junit5PluginVersion = "0.23" + and: + PitestTask task = getJustOnePitestTaskOrFail() + expect: + project.pitest.testPlugin.getOrNull() == null + and: + task.taskArgumentMap()['testPlugin'] == null + where: + pitVersion << ["1.0.0", "1.8.0"] } void "should not fail for unrecognised PIT version and assume newer one"() { From 09aeb45b8332e96877c21c92d5eaadf6abf51d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Sat, 12 Mar 2022 21:46:55 +0100 Subject: [PATCH 07/60] [#277] "Simplify" test with Groovy magic Is it really "simplified"? --- ...testTaskTestPluginConfigurationSpec.groovy | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskTestPluginConfigurationSpec.groovy b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskTestPluginConfigurationSpec.groovy index 696e467e..a6dcee79 100644 --- a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskTestPluginConfigurationSpec.groovy +++ b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskTestPluginConfigurationSpec.groovy @@ -17,17 +17,15 @@ class PitestTaskTestPluginConfigurationSpec extends BasicProjectBuilderSpec { expect: task.taskArgumentMap()['testPlugin'] == null where: - pitVersion | testPlugin | junit5PluginVersion - "1.6.7" | "junit5" | null - "1.6.8-SNAPSHOT" | "junit5" | null - "1.7.0" | "junit5" | null - "2.0.0" | "junit5" | null - "2.0" | "junit5" | null - "1.6.7" | null | "0.23" - "1.6.8-SNAPSHOT" | null | "0.23" - "1.7.0" | null | "0.23" - "2.0.0" | null | "0.23" - "2.0" | null | "0.23" + //Trick by Vampire: https://github.com/spockframework/spock/issues/1062#issuecomment-562807555 - is it more readable (see similar example below)? + [pitVersion, testPlugin, junit5PluginVersion] << [ + ["1.6.7", "1.6.8-SNAPSHOT", "1.7.0", "2.0.0", "2.0"], + [ + ["junit5", null], + [null, "0.23"], + + ] + ].combinations()*.flatten() } void "should pass testPlugin for backward compatibility for PIT <1.6.7 (#pitVersion, #testPlugin, #junit5PluginVersion)"() { From 703ea28033f9691bf34156b19bd0cc73ec30289a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Sat, 12 Mar 2022 23:57:24 +0100 Subject: [PATCH 08/60] Adjust test to remove hack for Gradle <6.0 compatibility --- .../functional/PitestPluginGradleVersionFunctionalSpec.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy index c3628ce7..e3331e85 100644 --- a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy +++ b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy @@ -73,7 +73,7 @@ class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSp @IgnoreIf({ new PreconditionContext().javaVersion >= 13 }) //There is no unsupported version of Gradle which can be used with Java 13 void "should fail with meaningful error message with too old Gradle version"() { given: - gradleVersion = "5.5.1" + gradleVersion = "6.0" //TODO: With 5.5.1 it fails with "ClassNotFoundException: org.gradle.api.file.FileSystemLocationProperty" anyway after removing compatibility hack and: assert PitestPlugin.MINIMAL_SUPPORTED_GRADLE_VERSION > GradleVersion.version(gradleVersion) when: From c1d02372f8a3d8e10183bf48052f4ff2920dee0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Sun, 13 Mar 2022 00:29:36 +0100 Subject: [PATCH 09/60] Trigger release [#DO_RELEASE][#1.7.4] From 5f3fa3f726b6450700fda6870d9c13a8dfef8217 Mon Sep 17 00:00:00 2001 From: Szpak CI Bot Date: Sat, 12 Mar 2022 23:31:13 +0000 Subject: [PATCH 10/60] Release version: 1.7.4 [ci skip] Powered by CDeliveryBoy. --- CHANGELOG.md | 2 +- README.md | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3c34725..9c99fb6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # gradle-pitest-plugin changelog -## 1.7.4 - Unreleased +## 1.7.4 - 2022-03-12 - Do not pass `--testPlugin` for PIT 1.6.7+ for forward compatibility - [#277](https://github.com/szpak/gradle-pitest-plugin/issues/277) - Deprecate `testPlugin` configuration parameter (not needed in [PIT 1.6.7+](https://github.com/hcoles/pitest/pull/900), to be removed in PIT 1.8.0) - [#277](https://github.com/szpak/gradle-pitest-plugin/issues/277) diff --git a/README.md b/README.md index cf16d5e8..40629517 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Add gradle-pitest-plugin to the `plugins` configuration in your `build.gradle` f ```groovy plugins { - id 'info.solidsoft.pitest' version '1.7.0' + id 'info.solidsoft.pitest' version '1.7.4' } ``` @@ -47,7 +47,7 @@ buildscript { //maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { - classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.7.0' + classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.7.4' } } ``` @@ -67,7 +67,7 @@ The Pitest plugin does not need to be additionally configured if you use JUnit 4 ```groovy pitest { targetClasses = ['our.base.package.*'] //by default "${project.group}.*" - pitestVersion = '1.7.0' //not needed when a default PIT version should be used + pitestVersion = '1.7.4' //not needed when a default PIT version should be used threads = 4 outputFormats = ['XML', 'HTML'] timestampedReports = false @@ -152,7 +152,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.7.0' + classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.7.4' } } @@ -179,7 +179,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.7.0' + classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.7.4' } } @@ -253,7 +253,7 @@ Starting with this release the configuration required to use PIT with JUnit 5 ha ```groovy plugins { id 'java' - id 'info.solidsoft.pitest' version '1.7.0' + id 'info.solidsoft.pitest' version '1.7.4' } pitest { @@ -276,7 +276,7 @@ To enable PIT plugins, it is enough to add it to the pitest configuration in the ```groovy plugins { id 'java' - id 'info.solidsoft.pitest' version '1.7.0' + id 'info.solidsoft.pitest' version '1.7.4' } repositories { From b4028af0a0a5f30a0ad0a79f9f19d8653ccc72af Mon Sep 17 00:00:00 2001 From: Ian O'Malley Date: Wed, 29 Jun 2022 16:23:31 -0400 Subject: [PATCH 11/60] Add pitest dependencies only during configuration resolution (#313) Resolves #302. --- .../pitest/PitestAggregatorPlugin.groovy | 20 +++++++++------- .../gradle/pitest/PitestPlugin.groovy | 24 +++++++++++-------- .../pitest/PitestAggregatorPluginTest.groovy | 4 ++-- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy index 57c85fe1..f1c980d7 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy @@ -52,13 +52,13 @@ class PitestAggregatorPlugin implements Plugin { return configuration } + addPitAggregateReportDependency(pitestReportConfiguration) project.tasks.register(PITEST_REPORT_AGGREGATE_TASK_NAME, AggregateReportTask) { t -> t.description = "Aggregate PIT reports" t.group = PitestPlugin.PITEST_TASK_GROUP configureTaskDefaults(t) //shouldRunAfter should be enough, but it fails in functional tests as :pitestReportAggregate is executed before :pitest tasks from subprojects t.mustRunAfter(project.allprojects.collect { Project p -> p.tasks.withType(PitestTask) }) - addPitAggregateReportDependency(pitestReportConfiguration) t.pitestReportClasspath.from(pitestReportConfiguration) } } @@ -79,14 +79,16 @@ class PitestAggregatorPlugin implements Plugin { } private void addPitAggregateReportDependency(Configuration pitestReportConfiguration) { - Optional maybeExtension = Optional.ofNullable(project.extensions.findByType(PitestPluginExtension)) - .map { extension -> Optional.of(extension) } //Optional::of with Groovy 3 - .orElseGet { findPitestExtensionInSubprojects(project) } - String pitestVersion = maybeExtension - .map { extension -> extension.pitestVersion.get() } - .orElse(PitestPlugin.DEFAULT_PITEST_VERSION) - - pitestReportConfiguration.dependencies.add(project.dependencies.create("org.pitest:pitest-aggregator:$pitestVersion")) + pitestReportConfiguration.withDependencies { dependencies -> + Optional maybeExtension = Optional.ofNullable(project.extensions.findByType(PitestPluginExtension)) + .map { extension -> Optional.of(extension) } //Optional::of with Groovy 3 + .orElseGet { findPitestExtensionInSubprojects(project) } + String pitestVersion = maybeExtension + .map { extension -> extension.pitestVersion.get() } + .orElse(PitestPlugin.DEFAULT_PITEST_VERSION) + + dependencies.add(project.dependencies.create("org.pitest:pitest-aggregator:$pitestVersion")) + } } private File getReportBaseDirectory() { diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index 6a0e5849..33b956a3 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -82,6 +82,7 @@ class PitestPlugin implements Plugin { project.plugins.withType(JavaPlugin).configureEach { setupExtensionWithDefaults() + addPitDependencies(pitestConfiguration) project.tasks.register(PITEST_TASK_NAME, PitestTask) { t -> failWithMeaningfulErrorMessageOnUnsupportedConfigurationInRootProjectBuildScript() t.description = "Run PIT analysis for java classes" @@ -89,7 +90,6 @@ class PitestPlugin implements Plugin { configureTaskDefault(t) t.dependsOn(calculateTasksToDependOn()) t.shouldRunAfter(project.tasks.named(TEST_TASK_NAME)) - addPitDependencies(pitestConfiguration) suppressPassingDeprecatedTestPluginForNewerPitVersions(t) } } @@ -217,21 +217,25 @@ class PitestPlugin implements Plugin { } private void addPitDependencies(Configuration pitestConfiguration) { - log.info("Using PIT: ${extension.pitestVersion.get()}") - pitestConfiguration.dependencies.add(project.dependencies.create("org.pitest:pitest-command-line:${extension.pitestVersion.get()}")) + pitestConfiguration.withDependencies { dependencies -> + log.info("Using PIT: ${extension.pitestVersion.get()}") + dependencies.add(project.dependencies.create("org.pitest:pitest-command-line:${extension.pitestVersion.get()}")) + } addPitJUnit5PluginIfRequested(pitestConfiguration) } private void addPitJUnit5PluginIfRequested(Configuration pitestConfiguration) { - if (extension.junit5PluginVersion.isPresent()) { - if (extension.testPlugin.isPresent() && extension.testPlugin.get() != PITEST_JUNIT5_PLUGIN_NAME) { - log.warn("Specified 'junit5PluginVersion', but other plugin is configured in 'testPlugin' for PIT: '${extension.testPlugin.get()}'") - } + pitestConfiguration.withDependencies { dependencies -> + if (extension.junit5PluginVersion.isPresent()) { + if (extension.testPlugin.isPresent() && extension.testPlugin.get() != PITEST_JUNIT5_PLUGIN_NAME) { + log.warn("Specified 'junit5PluginVersion', but other plugin is configured in 'testPlugin' for PIT: '${extension.testPlugin.get()}'") + } - String junit5PluginDependencyAsString = "org.pitest:pitest-junit5-plugin:${extension.junit5PluginVersion.get()}" - log.info("Adding JUnit 5 plugin for PIT as dependency: ${junit5PluginDependencyAsString}") - pitestConfiguration.dependencies.add(project.dependencies.create(junit5PluginDependencyAsString)) + String junit5PluginDependencyAsString = "org.pitest:pitest-junit5-plugin:${extension.junit5PluginVersion.get()}" + log.info("Adding JUnit 5 plugin for PIT as dependency: ${junit5PluginDependencyAsString}") + dependencies.add(project.dependencies.create(junit5PluginDependencyAsString)) + } } } diff --git a/src/test/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPluginTest.groovy b/src/test/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPluginTest.groovy index ec61d206..c0a79c72 100644 --- a/src/test/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPluginTest.groovy +++ b/src/test/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPluginTest.groovy @@ -26,7 +26,7 @@ class PitestAggregatorPluginTest extends Specification { and: triggerEvaluateForAggregateTask() then: - project.configurations.named("pitestReport").get().dependencies.find { dep -> + project.configurations.named("pitestReport").get().incoming.dependencies.find { dep -> dep.version == PitestPlugin.DEFAULT_PITEST_VERSION } } @@ -42,7 +42,7 @@ class PitestAggregatorPluginTest extends Specification { and: triggerEvaluateForAggregateTask() then: - project.configurations.named(PitestAggregatorPlugin.PITEST_REPORT_AGGREGATE_CONFIGURATION_NAME).get().dependencies.find { dep -> + project.configurations.named(PitestAggregatorPlugin.PITEST_REPORT_AGGREGATE_CONFIGURATION_NAME).get().incoming.dependencies.find { dep -> dep.version == testPitestVersion } } From 79b21bebb9a09a99c7a25503f2b2bb78129b0b4e Mon Sep 17 00:00:00 2001 From: Siddardha Bezawada Date: Thu, 4 Aug 2022 15:49:55 -0700 Subject: [PATCH 12/60] [#315] Use relativepath for file inputs --- .../groovy/info/solidsoft/gradle/pitest/PitestTask.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy index e4399c22..58201ea1 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy @@ -293,19 +293,19 @@ class PitestTask extends JavaExec { @Input String getAdditionalClasspathFilePath() { - return additionalClasspathFile.asFile.get().absolutePath + return additionalClasspathFile.asFile.get().relativePath(project.rootProject.rootDir) } @Input @Optional String getHistoryInputLocationPath() { //?. operator doesn't work with Gradle Providers - return historyInputLocation.isPresent() ? historyInputLocation.asFile.get().absolutePath : null + return historyInputLocation.isPresent() ? historyInputLocation.asFile.get().relativePath(project.rootProject.rootDir) : null } @Input String getDefaultFileForHistoryDataPath() { - return defaultFileForHistoryData.asFile.get().absolutePath + return defaultFileForHistoryData.asFile.get().relativePath(project.rootProject.rootDir) } @Input From d18f693cc331ecdeab51a16a1fb5914830386417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Mon, 8 Aug 2022 21:06:32 +0200 Subject: [PATCH 13/60] [#315] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c99fb6b..f7b42092 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # gradle-pitest-plugin changelog +## 1.9.0 - Unreleased + + - Improve build cache hit cache with relative path - [#315](https://github.com/szpak/gradle-pitest-plugin/issues/315) - PR by [Siddardha Bezawada](https://github.com/SidB3) + ## 1.7.4 - 2022-03-12 - Do not pass `--testPlugin` for PIT 1.6.7+ for forward compatibility - [#277](https://github.com/szpak/gradle-pitest-plugin/issues/277) From 49a26509737e773c36ad0d60ba3bf22238a5e8ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Mon, 8 Aug 2022 21:15:02 +0200 Subject: [PATCH 14/60] [#313] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7b42092..3590ed88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 1.9.0 - Unreleased + - Add pitest dependencies only during configuration resolution - [#313](https://github.com/szpak/gradle-pitest-plugin/issues/313) - PR by [Ian O'Malley](https://github.com/omalleyian) - Improve build cache hit cache with relative path - [#315](https://github.com/szpak/gradle-pitest-plugin/issues/315) - PR by [Siddardha Bezawada](https://github.com/SidB3) ## 1.7.4 - 2022-03-12 From 1086db2ba38bc56c4b5e00377c45d12ae0439a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 19 Aug 2022 18:54:49 +0200 Subject: [PATCH 15/60] PIT 1.9.4 by default --- CHANGELOG.md | 1 + build.gradle | 2 +- .../gradle/pitest/functional/Junit5FunctionalSpec.groovy | 6 +++--- .../resources/testProjects/junit5kotlin/build.gradle | 2 +- .../resources/testProjects/junit5kotlin/build.gradle.kts | 2 +- ...m-5.7.gradle => build-pit-1.8-junit-platform-5.7.gradle} | 1 + .../resources/testProjects/junit5simple/build.gradle | 4 ++-- .../resources/testProjects/junit5spock2/build.gradle | 2 +- .../groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy | 2 +- 9 files changed, 12 insertions(+), 10 deletions(-) rename src/funcTest/resources/testProjects/junit5simple/{build-junit-platform-5.7.gradle => build-pit-1.8-junit-platform-5.7.gradle} (87%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3590ed88..e38e9ff7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 1.9.0 - Unreleased + - PIT 1.9.4 by default - Add pitest dependencies only during configuration resolution - [#313](https://github.com/szpak/gradle-pitest-plugin/issues/313) - PR by [Ian O'Malley](https://github.com/omalleyian) - Improve build cache hit cache with relative path - [#315](https://github.com/szpak/gradle-pitest-plugin/issues/315) - PR by [Siddardha Bezawada](https://github.com/SidB3) diff --git a/build.gradle b/build.gradle index ecf13ef1..2f753511 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ buildscript { sourceCompatibility = 1.8 -ext.pitestAggregatorVersion = "1.7.4" //Must be equal to default PIT version in PitestPlugin +ext.pitestAggregatorVersion = "1.9.4" //Must be equal to default PIT version in PitestPlugin repositories { mavenCentral() diff --git a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy index b88e07ae..7f1985d8 100644 --- a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy +++ b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy @@ -48,9 +48,9 @@ class Junit5FunctionalSpec extends AbstractPitestFunctionalSpec { result.standardOutput.contains("junit-jupiter-api-${expectedJUnitJupiterVersion}.jar") result.standardOutput.contains("junit-platform-commons-${expectedJUnitPlatformVersion}.jar") where: - buildFileName || expectedJunitPluginVersion | expectedJUnitJupiterVersion | expectedJUnitPlatformVersion - 'build.gradle' || "0.15" | "5.8.0" | "1.8.0" - 'build-junit-platform-5.7.gradle' || "0.14" | "5.7.0" | "1.7.0" + buildFileName || expectedJunitPluginVersion | expectedJUnitJupiterVersion | expectedJUnitPlatformVersion + 'build.gradle' || "1.0.0" | "5.8.0" | "1.8.0" + 'build-pit-1.8-junit-platform-5.7.gradle' || "0.14" | "5.7.0" | "1.7.0" description = "plugin $expectedJunitPluginVersion, junit $expectedJUnitJupiterVersion, platform $expectedJUnitPlatformVersion" } diff --git a/src/funcTest/resources/testProjects/junit5kotlin/build.gradle b/src/funcTest/resources/testProjects/junit5kotlin/build.gradle index 56f21b6b..f01834d5 100644 --- a/src/funcTest/resources/testProjects/junit5kotlin/build.gradle +++ b/src/funcTest/resources/testProjects/junit5kotlin/build.gradle @@ -31,7 +31,7 @@ dependencies { testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version" testImplementation "org.junit.platform:junit-platform-runner:$junitPlatformVersion" - pitest 'org.pitest:pitest-junit5-plugin:0.14' + pitest 'org.pitest:pitest-junit5-plugin:1.0.0' } compileKotlin { diff --git a/src/funcTest/resources/testProjects/junit5kotlin/build.gradle.kts b/src/funcTest/resources/testProjects/junit5kotlin/build.gradle.kts index c29f4e65..835c5f73 100644 --- a/src/funcTest/resources/testProjects/junit5kotlin/build.gradle.kts +++ b/src/funcTest/resources/testProjects/junit5kotlin/build.gradle.kts @@ -42,7 +42,7 @@ tasks.withType { } configure { - junit5PluginVersion.set("0.14") + junit5PluginVersion.set("1.0.0") avoidCallsTo.set(setOf("kotlin.jvm.internal")) mutators.set(setOf("STRONGER")) targetClasses.set(setOf("pitest.test.*")) //by default "${project.group}.*" diff --git a/src/funcTest/resources/testProjects/junit5simple/build-junit-platform-5.7.gradle b/src/funcTest/resources/testProjects/junit5simple/build-pit-1.8-junit-platform-5.7.gradle similarity index 87% rename from src/funcTest/resources/testProjects/junit5simple/build-junit-platform-5.7.gradle rename to src/funcTest/resources/testProjects/junit5simple/build-pit-1.8-junit-platform-5.7.gradle index a39e2ff2..e00629b8 100644 --- a/src/funcTest/resources/testProjects/junit5simple/build-junit-platform-5.7.gradle +++ b/src/funcTest/resources/testProjects/junit5simple/build-pit-1.8-junit-platform-5.7.gradle @@ -34,6 +34,7 @@ test { } pitest { + pitestVersion = "1.8.1" //PIT 1.9.0 required junit5PluginVersion 1.0.0+ which doesn't support older JUnit Platform 1.7 // testPlugin = "junit5" //not needed - 'junit5PluginVersion' should implicitly set it junit5PluginVersion = "0.14" } diff --git a/src/funcTest/resources/testProjects/junit5simple/build.gradle b/src/funcTest/resources/testProjects/junit5simple/build.gradle index 2a04bdc4..afdf0cb5 100644 --- a/src/funcTest/resources/testProjects/junit5simple/build.gradle +++ b/src/funcTest/resources/testProjects/junit5simple/build.gradle @@ -20,7 +20,7 @@ repositories { dependencies { // //Not needed, 'junit5PluginVersion' should implicitly add it in requested version -// pitest 'org.pitest:pitest-junit5-plugin:0.12' +// pitest 'org.pitest:pitest-junit5-plugin:1.0.0' } group = "pitest.test" @@ -34,5 +34,5 @@ test { } pitest { - junit5PluginVersion = "0.15" + junit5PluginVersion = "1.0.0" } diff --git a/src/funcTest/resources/testProjects/junit5spock2/build.gradle b/src/funcTest/resources/testProjects/junit5spock2/build.gradle index b45334c9..7ae17f0c 100644 --- a/src/funcTest/resources/testProjects/junit5spock2/build.gradle +++ b/src/funcTest/resources/testProjects/junit5spock2/build.gradle @@ -30,5 +30,5 @@ test { } pitest { - junit5PluginVersion = "0.14" + junit5PluginVersion = "1.0.0" } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index 33b956a3..5dd005e1 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -52,7 +52,7 @@ class PitestPlugin implements Plugin { public final static String PITEST_REPORT_DIRECTORY_NAME = 'pitest' public final static String PITEST_CONFIGURATION_NAME = 'pitest' - public final static String DEFAULT_PITEST_VERSION = '1.7.4' + public final static String DEFAULT_PITEST_VERSION = '1.9.4' @Internal //6.4 due to main -> mainClass change to avoid deprecation warning in Gradle 7.x - https://github.com/szpak/gradle-pitest-plugin/pull/289 public static final GradleVersion MINIMAL_SUPPORTED_GRADLE_VERSION = GradleVersion.version("6.4") //public as used also in regression tests From c5e38dee23dc613b79ce24ed98e44a8cd7c47fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 19 Aug 2022 18:57:07 +0200 Subject: [PATCH 16/60] [#310] Support for inputEncoding and outputEncoding PIT 1.8.1+. In plugin named inputCharset and outputCharset. --- CHANGELOG.md | 6 +++++- .../pitest/AggregateReportGenerator.groovy | 12 +++++++++++ .../gradle/pitest/AggregateReportTask.groovy | 16 ++++++++++++++ .../AggregateReportWorkParameters.groovy | 5 +++++ .../pitest/PitestAggregatorPlugin.groovy | 19 ++++++++++++----- .../gradle/pitest/PitestPlugin.groovy | 2 ++ .../pitest/PitestPluginExtension.groovy | 19 ++++++++++++++++- .../solidsoft/gradle/pitest/PitestTask.groovy | 14 +++++++++++++ .../pitest/PitestAggregatorPluginTest.groovy | 2 ++ .../pitest/PitestTaskConfigurationSpec.groovy | 21 +++++++++++++++++++ 10 files changed, 109 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e38e9ff7..c49ae0ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,14 @@ ## 1.9.0 - Unreleased - - PIT 1.9.4 by default + - PIT 1.9.4 by default (requires pitest-junit5-plugin 1.0.0!) + - Support for `inputEncoding` and `outputEncoding` (named in plugin `inputCharset` and `outputCharset`) - [#310](https://github.com/szpak/gradle-pitest-plugin/issues/310) - Add pitest dependencies only during configuration resolution - [#313](https://github.com/szpak/gradle-pitest-plugin/issues/313) - PR by [Ian O'Malley](https://github.com/omalleyian) - Improve build cache hit cache with relative path - [#315](https://github.com/szpak/gradle-pitest-plugin/issues/315) - PR by [Siddardha Bezawada](https://github.com/SidB3) +**Compatibility notes** Due to the plugin API changes in PIT 1.9.0, the new pitest-junit5-plugin 1.0.0 is required (other PIT plugins - if used - also need to be upgraded). + + ## 1.7.4 - 2022-03-12 - Do not pass `--testPlugin` for PIT 1.6.7+ for forward compatibility - [#277](https://github.com/szpak/gradle-pitest-plugin/issues/277) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportGenerator.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportGenerator.groovy index c8e507c7..f3e265c6 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportGenerator.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportGenerator.groovy @@ -3,11 +3,14 @@ package info.solidsoft.gradle.pitest import groovy.transform.CompileStatic import groovy.util.logging.Slf4j import org.gradle.api.Incubating +import org.gradle.api.provider.Property import org.gradle.workers.WorkAction import org.pitest.aggregate.ReportAggregator import org.pitest.mutationtest.config.DirectoryResultOutputStrategy import org.pitest.mutationtest.config.UndatedReportDirCreationStrategy +import java.util.function.Consumer + @Slf4j @Incubating @CompileStatic @@ -23,6 +26,9 @@ abstract class AggregateReportGenerator implements WorkAction builder.addSourceCodeDirectory(file) } parameters.additionalClasspath.each { file -> builder.addCompiledCodeDirectory(file) } + consumeIfPropertyIsSet(parameters.inputCharset) { charset -> builder.inputCharSet(charset) } + consumeIfPropertyIsSet(parameters.outputCharset) { charset -> builder.outputCharset(charset) } + ReportAggregator aggregator = builder.resultOutputStrategy(new DirectoryResultOutputStrategy( parameters.reportDir.asFile.get().absolutePath, new UndatedReportDirCreationStrategy())) @@ -32,4 +38,10 @@ abstract class AggregateReportGenerator implements WorkAction void consumeIfPropertyIsSet(Property property, Consumer applyPropertyCode) { + if (property.isPresent()) { + applyPropertyCode.accept(property.get()) + } + } + } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy index b6966a34..743ea88d 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy @@ -7,8 +7,11 @@ import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.file.DirectoryProperty import org.gradle.api.file.RegularFileProperty import org.gradle.api.model.ObjectFactory +import org.gradle.api.provider.Property import org.gradle.api.tasks.Classpath +import org.gradle.api.tasks.Input import org.gradle.api.tasks.InputFiles +import org.gradle.api.tasks.Optional import org.gradle.api.tasks.OutputDirectory import org.gradle.api.tasks.OutputFile import org.gradle.api.tasks.PathSensitive @@ -19,6 +22,7 @@ import org.gradle.workers.WorkQueue import org.gradle.workers.WorkerExecutor import javax.inject.Inject +import java.nio.charset.Charset /** * Task to aggregate pitest report @@ -60,6 +64,14 @@ abstract class AggregateReportTask extends DefaultTask { @Classpath abstract ConfigurableFileCollection getPitestReportClasspath() + @Input + @Optional + final Property inputCharset + + @Input + @Optional + final Property outputCharset + @Inject abstract WorkerExecutor getWorkerExecutor() @@ -71,6 +83,8 @@ abstract class AggregateReportTask extends DefaultTask { additionalClasspath = of.fileCollection() mutationFiles = of.fileCollection() lineCoverageFiles = of.fileCollection() + inputCharset = of.property(Charset) + outputCharset = of.property(Charset) } @TaskAction @@ -87,6 +101,8 @@ abstract class AggregateReportTask extends DefaultTask { parameters.additionalClasspath.from(additionalClasspath) parameters.mutationFiles.from(mutationFiles) parameters.lineCoverageFiles.from(lineCoverageFiles) + parameters.inputCharset.set(this.inputCharset) + parameters.outputCharset.set(this.outputCharset) } } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportWorkParameters.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportWorkParameters.groovy index 08d63acd..2a44119d 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportWorkParameters.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportWorkParameters.groovy @@ -4,8 +4,11 @@ import org.gradle.api.Incubating import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.file.DirectoryProperty import org.gradle.api.file.RegularFileProperty +import org.gradle.api.provider.Property import org.gradle.workers.WorkParameters +import java.nio.charset.Charset + @Incubating interface AggregateReportWorkParameters extends WorkParameters { @@ -15,5 +18,7 @@ interface AggregateReportWorkParameters extends WorkParameters { ConfigurableFileCollection getAdditionalClasspath() ConfigurableFileCollection getMutationFiles() ConfigurableFileCollection getLineCoverageFiles() + Property getInputCharset() + Property getOutputCharset() } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy index f1c980d7..67bc8b00 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy @@ -13,6 +13,7 @@ import org.gradle.api.provider.Provider import org.gradle.api.reporting.ReportingExtension import org.gradle.api.tasks.TaskCollection +import java.util.function.Consumer import java.util.stream.Collectors /** @@ -64,7 +65,7 @@ class PitestAggregatorPlugin implements Plugin { } private void configureTaskDefaults(AggregateReportTask aggregateReportTask) { - aggregateReportTask.with { + aggregateReportTask.with { task -> reportDir.set(new File(getReportBaseDirectory(), PitestPlugin.PITEST_REPORT_DIRECTORY_NAME)) reportFile.set(reportDir.file("index.html")) @@ -75,15 +76,17 @@ class PitestAggregatorPlugin implements Plugin { Set projectsWithPitest = getProjectsWithPitestPlugin() mutationFiles.from = collectMutationFiles(projectsWithPitest) lineCoverageFiles.from = collectLineCoverageFiles(projectsWithPitest) + + findPluginExtension().ifPresent({ PitestPluginExtension extension -> + inputCharset.set(extension.inputCharset) + outputCharset.set(extension.outputCharset) + } as Consumer) //Simplify with Groovy 3+ } } private void addPitAggregateReportDependency(Configuration pitestReportConfiguration) { pitestReportConfiguration.withDependencies { dependencies -> - Optional maybeExtension = Optional.ofNullable(project.extensions.findByType(PitestPluginExtension)) - .map { extension -> Optional.of(extension) } //Optional::of with Groovy 3 - .orElseGet { findPitestExtensionInSubprojects(project) } - String pitestVersion = maybeExtension + String pitestVersion = findPluginExtension() .map { extension -> extension.pitestVersion.get() } .orElse(PitestPlugin.DEFAULT_PITEST_VERSION) @@ -91,6 +94,12 @@ class PitestAggregatorPlugin implements Plugin { } } + private Optional findPluginExtension() { + return Optional.ofNullable(project.extensions.findByType(PitestPluginExtension)) + .map { extension -> Optional.of(extension) } //Optional::of with Groovy 3 + .orElseGet { findPitestExtensionInSubprojects(project) } + } + private File getReportBaseDirectory() { if (project.extensions.findByType(ReportingExtension)) { return project.extensions.getByType(ReportingExtension).baseDir diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index 5dd005e1..a978fba9 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -201,6 +201,8 @@ class PitestPlugin implements Plugin { task.pluginConfiguration.set(extension.pluginConfiguration) task.maxSurviving.set(extension.maxSurviving) task.useClasspathJar.set(extension.useClasspathJar) + task.inputEncoding.set(extension.inputCharset) + task.outputEncoding.set(extension.outputCharset) task.features.set(extension.features) } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy index e6e8dd04..0d7597a7 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy @@ -28,6 +28,8 @@ import org.gradle.api.provider.Provider import org.gradle.api.provider.SetProperty import org.gradle.api.tasks.SourceSet +import java.nio.charset.Charset + /** * Extension class with configurable parameters for Pitest plugin. * @@ -178,8 +180,11 @@ class PitestPluginExtension { @Incubating final Property useClasspathJar //new in PIT 1.4.2 (GPP 1.4.6) + final Property inputCharset //new in PIT 1.8.1 as inputEncoding (GPP 1.9.0) + final Property outputCharset //new in PIT 1.8.1 as outputEncoding (GPP 1.9.0) + /** - * Turnes on/off features in PIT itself and its plugins. + * Turns on/off features in PIT itself and its plugins. * * Some details: https://github.com/hcoles/pitest/releases/tag/pitest-parent-1.2.1 * @@ -263,6 +268,8 @@ class PitestPluginExtension { pluginConfiguration = nullMapPropertyOf(p, String, String) maxSurviving = of.property(Integer) useClasspathJar = of.property(Boolean) + inputCharset = of.property(Charset) + outputCharset = of.property(Charset) features = nullListPropertyOf(p, String) fileExtensionsToFilter = nullListPropertyOf(p, String) } @@ -296,6 +303,16 @@ class PitestPluginExtension { this.enableDefaultIncrementalAnalysis.set(withHistory) } + @Deprecated //Alias for inputCharset to keep naming compatibility with PIT + void setInputEncoding(Charset inputCharset) { + this.inputCharset.set(inputCharset) + } + + @Deprecated //Alias for outputCharset to keep naming compatibility with PIT + void setOutputEncoding(Charset outputCharset) { + this.outputCharset.set(outputCharset) + } + private static SetProperty nullSetPropertyOf(Project p, Class clazz) { return p.objects.setProperty(clazz).convention(p.providers.provider { null } as Provider) //coercion due to "red" warning in Idea } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy index 58201ea1..c2a2df2a 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy @@ -40,6 +40,8 @@ import org.gradle.api.tasks.PathSensitive import org.gradle.api.tasks.PathSensitivity import org.gradle.api.tasks.options.Option +import java.nio.charset.Charset + /** * Gradle task implementation for Pitest. */ @@ -223,6 +225,14 @@ class PitestTask extends JavaExec { @Optional final Property useClasspathJar + @Input + @Optional + final Property inputEncoding + + @Input + @Optional + final Property outputEncoding + @Input @Optional final ListProperty features @@ -285,6 +295,8 @@ class PitestTask extends JavaExec { pluginConfiguration = of.mapProperty(String, String) maxSurviving = of.property(Integer) useClasspathJar = of.property(Boolean) + inputEncoding = of.property(Charset) + outputEncoding = of.property(Charset) additionalClasspath = of.fileCollection() useAdditionalClasspathFile = of.property(Boolean) additionalClasspathFile = of.fileProperty() @@ -367,6 +379,8 @@ class PitestTask extends JavaExec { map['jvmPath'] = getJvmPath()?.getOrNull()?.asFile?.absolutePath map['maxSurviving'] = optionalPropertyAsString(maxSurviving) map['useClasspathJar'] = optionalPropertyAsString(useClasspathJar) + map['inputEncoding'] = optionalPropertyAsString(inputEncoding) + map['outputEncoding'] = optionalPropertyAsString(outputEncoding) map['features'] = (features.getOrElse([]) + (additionalFeatures ?: []))?.join(',') map.putAll(prepareMapWithClasspathConfiguration()) map.putAll(prepareMapWithIncrementalAnalysisConfiguration()) diff --git a/src/test/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPluginTest.groovy b/src/test/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPluginTest.groovy index c0a79c72..3631b4cb 100644 --- a/src/test/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPluginTest.groovy +++ b/src/test/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPluginTest.groovy @@ -49,6 +49,8 @@ class PitestAggregatorPluginTest extends Specification { // void "use pitest version from subproject project configuration"() {} //TODO: Can be implemented with ProjectBuilder? withParent()? +// void "use configured charset in aggregation"() {} //TODO: Can be tested in "unit" way? + private void assertThatTasksAreInGroup(List taskNames, String group) { taskNames.each { String taskName -> Task task = project.tasks[taskName] diff --git a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy index 4d96de7d..0883cba2 100644 --- a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy +++ b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy @@ -18,6 +18,8 @@ package info.solidsoft.gradle.pitest import groovy.transform.CompileDynamic import spock.lang.Issue +import java.nio.charset.Charset + //TODO: Think if task initialization with WithPitestTaskInitialization is not performed to early // (see PitestTaskTestPluginConfigurationSpec for corner case with login in PitestPlugin) @CompileDynamic @@ -56,6 +58,10 @@ class PitestTaskConfigurationSpec extends BasicProjectBuilderSpec implements Wit 'jvmPath', 'maxSurviving', 'useClasspathJar', + 'inputCharset', + 'outputCharset', + 'inputEncoding', + 'outputEncoding', 'features', 'historyInputLocation', 'historyOutputLocation', @@ -168,6 +174,9 @@ class PitestTaskConfigurationSpec extends BasicProjectBuilderSpec implements Wit //pluginConfiguration tested separately "maxSurviving" | 20 || "20" "useClasspathJar" | true || "true" + //inputCharset and outputCharset tested separately - they set inputEncoding and outputEncoding in PIT + "inputEncoding" | Charset.forName("ISO-8859-2") || "ISO-8859-2" + "outputEncoding" | Charset.forName("ISO-8859-1") || "ISO-8859-1" "features" | ["-FOO", "+BAR(a[1] a[2])"] || "-FOO,+BAR(a[1] a[2])" //fileExtensionsToFilter not passed to PIT, tested separately } @@ -249,6 +258,18 @@ class PitestTaskConfigurationSpec extends BasicProjectBuilderSpec implements Wit ] as Set } + void "should set input/output encoding in PIT for input/output charset"() { + given: + String inputEncodingAsString = "ISO-8859-2" + String outputEncodingAsString = "ISO-8859-1" + and: + project.pitest.inputCharset = Charset.forName(inputEncodingAsString) + project.pitest.outputCharset = Charset.forName(outputEncodingAsString) + expect: + task.taskArgumentMap()['inputEncoding'] == inputEncodingAsString + task.taskArgumentMap()['outputEncoding'] == outputEncodingAsString + } + private Set assembleMainSourceDirAsStringSet() { return ["resources", "java"].collect { String dirName -> new File(project.projectDir, "src/main/${dirName}") From a4b4a73d37b59879ef00141e92e31afb94588ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 19 Aug 2022 21:53:16 +0200 Subject: [PATCH 17/60] [#311] Remove dependencyDistance parameter Removed in PIT 1.9.0. --- CHANGELOG.md | 2 ++ .../groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy | 1 - .../solidsoft/gradle/pitest/PitestPluginExtension.groovy | 2 -- .../groovy/info/solidsoft/gradle/pitest/PitestTask.groovy | 6 ------ .../gradle/pitest/PitestTaskConfigurationSpec.groovy | 2 -- 5 files changed, 2 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c49ae0ee..67ce7a57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - Support for `inputEncoding` and `outputEncoding` (named in plugin `inputCharset` and `outputCharset`) - [#310](https://github.com/szpak/gradle-pitest-plugin/issues/310) - Add pitest dependencies only during configuration resolution - [#313](https://github.com/szpak/gradle-pitest-plugin/issues/313) - PR by [Ian O'Malley](https://github.com/omalleyian) - Improve build cache hit cache with relative path - [#315](https://github.com/szpak/gradle-pitest-plugin/issues/315) - PR by [Siddardha Bezawada](https://github.com/SidB3) + - Remove (optional) `dependencyDistance` configuration parameter removed in PIT 1.9.0 + **Compatibility notes** Due to the plugin API changes in PIT 1.9.0, the new pitest-junit5-plugin 1.0.0 is required (other PIT plugins - if used - also need to be upgraded). diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index a978fba9..7b23330c 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -148,7 +148,6 @@ class PitestPlugin implements Plugin { return task.targetClasses.getOrNull() } } as Provider>) - task.dependencyDistance.set(extension.dependencyDistance) task.threads.set(extension.threads) task.mutators.set(extension.mutators) task.excludedMethods.set(extension.excludedMethods) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy index 0d7597a7..722398c4 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy @@ -74,7 +74,6 @@ class PitestPluginExtension { final SetProperty targetClasses final SetProperty targetTests - final Property dependencyDistance final Property threads final SetProperty mutators final SetProperty excludedMethods @@ -231,7 +230,6 @@ class PitestPluginExtension { reportDir = of.directoryProperty() targetClasses = nullSetPropertyOf(p, String) //null instead of empty collection to distinguish on optional parameters targetTests = nullSetPropertyOf(p, String) - dependencyDistance = of.property(Integer) threads = of.property(Integer) mutators = nullSetPropertyOf(p, String) excludedMethods = nullSetPropertyOf(p, String) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy index c2a2df2a..acd2dbff 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy @@ -66,10 +66,6 @@ class PitestTask extends JavaExec { @Optional final SetProperty targetTests - @Input - @Optional - final Property dependencyDistance - @Input @Optional final Property threads @@ -258,7 +254,6 @@ class PitestTask extends JavaExec { reportDir = of.directoryProperty() targetClasses = of.setProperty(String) targetTests = of.setProperty(String) - dependencyDistance = of.property(Integer) threads = of.property(Integer) mutators = of.setProperty(String) excludedMethods = of.setProperty(String) @@ -348,7 +343,6 @@ class PitestTask extends JavaExec { map['reportDir'] = reportDir.getOrNull()?.toString() map['targetClasses'] = targetClasses.get().join(',') map['targetTests'] = overriddenTargetTests ? overriddenTargetTests.join(',') : optionalCollectionAsString(targetTests) - map['dependencyDistance'] = optionalPropertyAsString(dependencyDistance) map['threads'] = optionalPropertyAsString(threads) map["mutators"] = optionalCollectionAsString(mutators) map['excludedMethods'] = optionalCollectionAsString(excludedMethods) diff --git a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy index 0883cba2..a7ead0e2 100644 --- a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy +++ b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy @@ -30,7 +30,6 @@ class PitestTaskConfigurationSpec extends BasicProjectBuilderSpec implements Wit 'features', 'excludedTestClasses', 'testPlugin', - 'dependencyDistance', 'threads', "mutators", 'excludedMethods', @@ -139,7 +138,6 @@ class PitestTaskConfigurationSpec extends BasicProjectBuilderSpec implements Wit "reportDir" | new File("//tmp//foo") || new File("//tmp//foo").path //due to issues on Windows "targetClasses" | ["a", "b"] || "a,b" "targetTests" | ["t1", "t2"] || "t1,t2" - "dependencyDistance" | 42 || "42" "threads" | 42 || "42" "mutators" | ["MUTATOR_X", "MUTATOR_Y", "-MUTATOR_Z"] || "MUTATOR_X,MUTATOR_Y,-MUTATOR_Z" "excludedMethods" | ["methodX", "methodY"] || "methodX,methodY" From de0cbcd9aad3ba54fc7e275037296204456a9f06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 19 Aug 2022 22:01:58 +0200 Subject: [PATCH 18/60] Bump minor dependencies --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2f753511..aac58731 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ buildscript { classpath 'info.solidsoft.gradle:cdeliveryboy:0.8.0' classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0' //override version for more reliable releasing from Travis classpath 'com.gradle.publish:plugin-publish-plugin:0.16.0' - classpath 'com.github.ben-manes:gradle-versions-plugin:0.39.0' + classpath 'com.github.ben-manes:gradle-versions-plugin:0.42.0' } } From 4e0ada81321051499ee4abc682e33040fa70387a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 19 Aug 2022 22:03:01 +0200 Subject: [PATCH 19/60] Upgrade Spock to 2.2-M3 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index aac58731..c104c063 100644 --- a/build.gradle +++ b/build.gradle @@ -39,11 +39,11 @@ dependencies { implementation localGroovy() compileOnly "org.pitest:pitest-aggregator:$pitestAggregatorVersion" - testImplementation('org.spockframework:spock-core:2.0-groovy-2.5') { + testImplementation('org.spockframework:spock-core:2.2-M3-groovy-2.5') { exclude group: 'org.codehaus.groovy' } //for "@Rule TemporaryFolder" - testImplementation('org.spockframework:spock-junit4:2.0-groovy-2.5') { + testImplementation('org.spockframework:spock-junit4:2.2-M3-groovy-2.5') { exclude group: 'org.codehaus.groovy' } testImplementation 'net.bytebuddy:byte-buddy:1.11.16' //for Spying in Spock From 0ab53f268e6ac89b5ee70679f669f09098c6fba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 19 Aug 2022 22:05:13 +0200 Subject: [PATCH 20/60] Update Gradle versions in regression tests --- .../PitestPluginGradleVersionFunctionalSpec.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy index e3331e85..e08c4e11 100644 --- a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy +++ b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy @@ -31,7 +31,7 @@ import static info.solidsoft.gradle.pitest.PitestTaskConfigurationSpec.PIT_PARAM @CompileDynamic class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSpec { - private static final GradleVersion LATEST_KNOWN_GRADLE_VERSION = GradleVersion.version("7.4.1") + private static final GradleVersion LATEST_KNOWN_GRADLE_VERSION = GradleVersion.version("7.5.1") //Baased on https://docs.gradle.org/current/userguide/compatibility.html private static final Map MINIMAL_GRADLE_VERSION_FOR_JAVA_VERSION = [ @@ -100,9 +100,9 @@ class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSp //TODO: Extract regression tests control mechanism to a separate class (or even better trait) when needed in some other place private static final String REGRESSION_TESTS_ENV_NAME = "PITEST_REGRESSION_TESTS" - private static final List GRADLE6_VERSIONS = ["6.9.1", "6.8.3", "6.7", "6.6", "6.5", + private static final List GRADLE6_VERSIONS = ["6.9.2", "6.8.3", "6.7", "6.6", "6.5", PitestPlugin.MINIMAL_SUPPORTED_GRADLE_VERSION.version] - private static final List GRADLE7_VERSIONS = [LATEST_KNOWN_GRADLE_VERSION.version, "7.3.3", "7.2", "7.1.1", "7.0.2"] + private static final List GRADLE7_VERSIONS = [LATEST_KNOWN_GRADLE_VERSION.version, "7.4.1", "7.3.3", "7.2", "7.1.1", "7.0.2"] private static final List GRADLE_LATEST_VERSIONS = [GRADLE6_VERSIONS.first(), GRADLE7_VERSIONS.first(), PitestPlugin.MINIMAL_SUPPORTED_GRADLE_VERSION.version] From 9d83137b70a85f826c985cf120a026026b4120d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 19 Aug 2022 22:19:59 +0200 Subject: [PATCH 21/60] [#299] Deprecate support for Java 8 The plugin is released with JDK 11. (the source/class compatibility is still JDK 8, but it might chance without notice). --- .travis.yml | 4 +--- CHANGELOG.md | 5 ++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7b056ef1..b0737093 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,10 +34,8 @@ env: - secure: FZfezOymfoKWQf+DHb6OU2Vk1cY8Cz0ic3+ZtPKoWRrp8bijkSIA8jjfzwKNbJ1qyRthTY7tv/k83dbrOl3xDBeT6yzXslceraWLww/cp/+FGM6M3XG6dLqZlSaKH8bbPL94p7NiPCn+7mSuirur1H9Lf4lD6VeAOmxtstowPic= matrix: include: - - jdk: openjdk8 - env: PITEST_REGRESSION_TESTS=quick - jdk: openjdk11 - env: PITEST_REGRESSION_TESTS=quick SKIP_RELEASE=true + env: PITEST_REGRESSION_TESTS=quick - jdk: openjdk15 env: PITEST_REGRESSION_TESTS=latestOnly SKIP_RELEASE=true - env: JDK="OpenJ9 11" PITEST_REGRESSION_TESTS=quick SKIP_RELEASE=true diff --git a/CHANGELOG.md b/CHANGELOG.md index 67ce7a57..e12c90d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,13 +3,16 @@ ## 1.9.0 - Unreleased - PIT 1.9.4 by default (requires pitest-junit5-plugin 1.0.0!) + - Deprecate support for JDK 8 - [#299](https://github.com/szpak/gradle-pitest-plugin/issues/299) - Support for `inputEncoding` and `outputEncoding` (named in plugin `inputCharset` and `outputCharset`) - [#310](https://github.com/szpak/gradle-pitest-plugin/issues/310) - Add pitest dependencies only during configuration resolution - [#313](https://github.com/szpak/gradle-pitest-plugin/issues/313) - PR by [Ian O'Malley](https://github.com/omalleyian) - Improve build cache hit cache with relative path - [#315](https://github.com/szpak/gradle-pitest-plugin/issues/315) - PR by [Siddardha Bezawada](https://github.com/SidB3) - Remove (optional) `dependencyDistance` configuration parameter removed in PIT 1.9.0 -**Compatibility notes** Due to the plugin API changes in PIT 1.9.0, the new pitest-junit5-plugin 1.0.0 is required (other PIT plugins - if used - also need to be upgraded). +**Compatibility notes** +1. Due to the plugin API changes in PIT 1.9.0, the new pitest-junit5-plugin 1.0.0 is required (other PIT plugins - if used - also need to be upgraded). +2. The plugin is released with JDK 11. Source/class compatibility is still set to JDK 8, but this might change without notice. ## 1.7.4 - 2022-03-12 From f3f05d3210c68f570af1757f530a5e7faa13f311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 19 Aug 2022 22:24:57 +0200 Subject: [PATCH 22/60] [#299] Minor README update --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 40629517..bcf5b729 100644 --- a/README.md +++ b/README.md @@ -258,12 +258,12 @@ plugins { pitest { //adds dependency to org.pitest:pitest-junit5-plugin and sets "testPlugin" to "junit5" - junit5PluginVersion = '0.15' //or 0.14 for Junit Jupiter 5.7 (JUnit Platform 1.7) + junit5PluginVersion = '1.0.0' //or 0.15 for PIT <1.9.0 // ... } ``` -**Please note**. JUnit Jupiter 5.8 (JUnit Platform 1.8) requires pitest-junit5-plugin 0.15+, while 5.7 (1.7) requires 0.14. Set right plugin version for JUnit 5 version used in your project to avoid runtime errors (such as [`NoSuchMethodError: 'java.util.Optional org.junit.platform.commons.util.AnnotationUtils.findAnnotation(java.lang.Class, java.lang.Class, boolean)'](https://github.com/szpak/gradle-pitest-plugin/issues/300))). +**Please note**. PIT 1.9.0 requires pitest-junit5-plugin 1.0.0+. JUnit Jupiter 5.8 (JUnit Platform 1.8) requires pitest-junit5-plugin 0.15+, while 5.7 (1.7) requires 0.14. Set right plugin version for JUnit 5 version used in your project to avoid runtime errors (such as [`NoSuchMethodError: 'java.util.Optional org.junit.platform.commons.util.AnnotationUtils.findAnnotation(java.lang.Class, java.lang.Class, boolean)'](https://github.com/szpak/gradle-pitest-plugin/issues/300))). The minimal working example for JUnit 5 is available in the [functional tests suite](https://github.com/szpak/gradle-pitest-plugin/blob/master/src/funcTest/resources/testProjects/junit5simple/build.gradle). @@ -301,16 +301,16 @@ in a `pitest` configuration closure. Please be aware that in some cases there could be some issues when using non default PIT versions. -If not stated otherwise, gradle-pitest-plugin 1.7.x by default uses PIT 1.7.x, 1.6.x uses PIT 1.6.x, etc. +If not stated otherwise, gradle-pitest-plugin 1.9.x by default uses PIT 1.9.x, 1.7.x uses PIT 1.7.x, etc. Starting with version 1.7.0 gradle-pitest-plugin requires Gradle 6.4. The latest version with the Gradle 5.x (5.6+) support is 1.6.0. -The current version was automatically smoke tested with Gradle 6.4, 6.9.1 and 7.2 under Java 8. -Tests with Java 9 - 15 are limited to the compatible versions of Gradle and PIT. +The current version was automatically smoke tested with Gradle 6.4, 6.9.1 and 7.4.2 under Java 11. +Tests with Java 11+ are limited to the compatible versions of Gradle and PIT. -Java 11 is officially supported starting with gradle-pitest-plugin 1.4.0. The experimental support for Java 17 can be tested with 1.7.0+. +The experimental support for Java 17 can be tested with 1.7.0+. Starting with the version 1.3.0 the produced binaries [require](https://github.com/szpak/gradle-pitest-plugin/issues/70#issuecomment-360989155) Java 8 -(as a JDK used for running a Gradle build). However, having Java 17 LTS released, support for JDK <11 can be deprecated "soon" (see [#299](https://github.com/szpak/gradle-pitest-plugin/issues/299)). +(as a JDK used for running a Gradle build). However, having Java 17 LTS released in September 2021, starting with gradle-pitest-plugin 1.9.0, support for JDK <11 is deprecated (see [#299](https://github.com/szpak/gradle-pitest-plugin/issues/299)). See the [changelog file](https://github.com/szpak/gradle-pitest-plugin/blob/master/CHANGELOG.md) for more detailed list of changes in the plugin itself. From 0826aa5106d045379fd9843011f9dd0f1225975c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 19 Aug 2022 22:26:21 +0200 Subject: [PATCH 23/60] Trigger release [#DO_RELEASE][#1.9.0] From 6b810a2fd73309c12ce4bcbecac502bac50a3423 Mon Sep 17 00:00:00 2001 From: Szpak CI Bot Date: Fri, 19 Aug 2022 20:33:55 +0000 Subject: [PATCH 24/60] Release version: 1.9.0 [ci skip] Powered by CDeliveryBoy. --- CHANGELOG.md | 2 +- README.md | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e12c90d8..dfc2a2ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # gradle-pitest-plugin changelog -## 1.9.0 - Unreleased +## 1.9.0 - 2022-08-19 - PIT 1.9.4 by default (requires pitest-junit5-plugin 1.0.0!) - Deprecate support for JDK 8 - [#299](https://github.com/szpak/gradle-pitest-plugin/issues/299) diff --git a/README.md b/README.md index bcf5b729..f540bc93 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Add gradle-pitest-plugin to the `plugins` configuration in your `build.gradle` f ```groovy plugins { - id 'info.solidsoft.pitest' version '1.7.4' + id 'info.solidsoft.pitest' version '1.9.0' } ``` @@ -47,7 +47,7 @@ buildscript { //maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { - classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.7.4' + classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.9.0' } } ``` @@ -67,7 +67,7 @@ The Pitest plugin does not need to be additionally configured if you use JUnit 4 ```groovy pitest { targetClasses = ['our.base.package.*'] //by default "${project.group}.*" - pitestVersion = '1.7.4' //not needed when a default PIT version should be used + pitestVersion = '1.9.0' //not needed when a default PIT version should be used threads = 4 outputFormats = ['XML', 'HTML'] timestampedReports = false @@ -152,7 +152,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.7.4' + classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.9.0' } } @@ -179,7 +179,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.7.4' + classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.9.0' } } @@ -253,7 +253,7 @@ Starting with this release the configuration required to use PIT with JUnit 5 ha ```groovy plugins { id 'java' - id 'info.solidsoft.pitest' version '1.7.4' + id 'info.solidsoft.pitest' version '1.9.0' } pitest { @@ -276,7 +276,7 @@ To enable PIT plugins, it is enough to add it to the pitest configuration in the ```groovy plugins { id 'java' - id 'info.solidsoft.pitest' version '1.7.4' + id 'info.solidsoft.pitest' version '1.9.0' } repositories { From 5645dd5edf157a18bc7c1e13f3112e6e6e32ab42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Sat, 20 Aug 2022 11:20:16 +0200 Subject: [PATCH 25/60] [#311] Update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfc2a2ae..f5276b27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - Support for `inputEncoding` and `outputEncoding` (named in plugin `inputCharset` and `outputCharset`) - [#310](https://github.com/szpak/gradle-pitest-plugin/issues/310) - Add pitest dependencies only during configuration resolution - [#313](https://github.com/szpak/gradle-pitest-plugin/issues/313) - PR by [Ian O'Malley](https://github.com/omalleyian) - Improve build cache hit cache with relative path - [#315](https://github.com/szpak/gradle-pitest-plugin/issues/315) - PR by [Siddardha Bezawada](https://github.com/SidB3) - - Remove (optional) `dependencyDistance` configuration parameter removed in PIT 1.9.0 + - Remove (optional) `dependencyDistance` configuration parameter removed in PIT 1.9.0 - [#311](https://github.com/szpak/gradle-pitest-plugin/issues/311) **Compatibility notes** From 12857274f550d5a21d570621934bb86d5af16c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Thu, 25 Aug 2022 23:52:08 +0200 Subject: [PATCH 26/60] [#316] Improve multiproject configuration in README --- README.md | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index f540bc93..469adea4 100644 --- a/README.md +++ b/README.md @@ -141,23 +141,19 @@ Similar syntax can be used also for Kotlin configuration (`build.gradle.kts`). ## Multi-module projects support -gradle-pitest-plugin can be used in multi-module projects. The gradle-pitest-plugin dependency should be added to the buildscript configuration in -the root project while the plugin has to be applied in all subprojects which should be processed with PIT. A sample snippet from build.gradle located -for the root project: +gradle-pitest-plugin can be used in [multi-module projects](src/funcTest/resources/testProjects/multiproject/build.gradle). +The gradle-pitest-plugin dependency should be added to the buildscript configuration in the root project while the plugin has to be applied in +all subprojects which should be processed with PIT. A sample snippet from build.gradle located for the root project: ```groovy //in root project configuration -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.9.0' - } +plugins { + id 'info.solidsoft.pitest' version '1.9.0' apply false } subprojects { - apply plugin: 'info.solidsoft.pitest' //'pitest' for plugin versions <1.1.0 + apply plugin: 'java' + apply plugin: 'info.solidsoft.pitest' pitest { threads = 4 @@ -174,18 +170,14 @@ task `pitestReportAggregate`. Root project must be properly configured to use `p ```groovy //in root project configuration -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.9.0' - } +plugins { + id 'info.solidsoft.pitest' version '1.9.0' apply false } apply plugin: 'info.solidsoft.pitest.aggregator' // to 'pitestReportAggregate' appear subprojects { + apply plugin: 'java' apply plugin: 'info.solidsoft.pitest' pitest { From 27c7e5eb5570c1ed2f9e1582093c82db000359e7 Mon Sep 17 00:00:00 2001 From: Carsten Otto Date: Thu, 17 Nov 2022 17:52:08 +0100 Subject: [PATCH 27/60] fix typos --- README.md | 2 +- .../solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 469adea4..22c7caef 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ The expected parameter format in a plugin configuration can be taken from [PitestPluginExtension](https://github.com/szpak/gradle-pitest-plugin/blob/master/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy). To make life easier `taskClasspath`, `mutableCodePaths`, `sourceDirs`, `reportDir` and `pitestVersion` are -automatically set by a plugin. In addition `sourceDirs`, `reportDir` and `pitestVersion` can be overridden by an user. +automatically set by a plugin. In addition `sourceDirs`, `reportDir` and `pitestVersion` can be overridden by a user. There are a few parameters specific for Gradle plugin: diff --git a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy index a7ead0e2..670b641c 100644 --- a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy +++ b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy @@ -113,7 +113,7 @@ class PitestTaskConfigurationSpec extends BasicProjectBuilderSpec implements Wit void "should not pass features configuration to PIT if not set in configuration or via option"() { //Intentional duplication with generic parametrized tests to emphasis requirement expect: - task.taskArgumentMap()['featues'] == null + task.taskArgumentMap()['features'] == null } void "should not pass to PIT parameter '#paramName' by default if not set explicitly"() { From 44f374ae40ff79ac419c708430b39487d736b8da Mon Sep 17 00:00:00 2001 From: Carsten Otto Date: Thu, 17 Nov 2022 18:09:05 +0100 Subject: [PATCH 28/60] add support for "verbosity" flag, disable spinner by default fixes #267 --- .../solidsoft/gradle/pitest/PitestPlugin.groovy | 2 ++ .../gradle/pitest/PitestPluginExtension.groovy | 2 ++ .../info/solidsoft/gradle/pitest/PitestTask.groovy | 6 ++++++ .../pitest/PitestTaskConfigurationSpec.groovy | 13 +++++++++++++ 4 files changed, 23 insertions(+) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index 7b23330c..4ce4b91b 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -112,6 +112,7 @@ class PitestPlugin implements Plugin { extension.mainSourceSets.set([javaSourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)]) extension.fileExtensionsToFilter.set(DEFAULT_FILE_EXTENSIONS_TO_FILTER_FROM_CLASSPATH) extension.useClasspathFile.set(false) + extension.verbosity.set("NO_SPINNER") } private void failWithMeaningfulErrorMessageOnUnsupportedConfigurationInRootProjectBuildScript() { @@ -155,6 +156,7 @@ class PitestPlugin implements Plugin { task.excludedTestClasses.set(extension.excludedTestClasses) task.avoidCallsTo.set(extension.avoidCallsTo) task.verbose.set(extension.verbose) + task.verbosity.set(extension.verbosity) task.timeoutFactor.set(extension.timeoutFactor) task.timeoutConstInMillis.set(extension.timeoutConstInMillis) task.childProcessJvmArgs.set(extension.jvmArgs) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy index 722398c4..40a20980 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy @@ -90,6 +90,7 @@ class PitestPluginExtension { final SetProperty excludedTestClasses final SetProperty avoidCallsTo final Property verbose + final Property verbosity final Property timeoutFactor final Property timeoutConstInMillis /** @@ -237,6 +238,7 @@ class PitestPluginExtension { excludedTestClasses = nullSetPropertyOf(p, String) avoidCallsTo = nullSetPropertyOf(p, String) verbose = of.property(Boolean) + verbosity = of.property(String) timeoutFactor = of.property(BigDecimal) timeoutConstInMillis = of.property(Integer) jvmArgs = nullListPropertyOf(p, String) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy index acd2dbff..311b4ad2 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy @@ -94,6 +94,10 @@ class PitestTask extends JavaExec { @Optional final Property verbose + @Input + @Optional + final Property verbosity + @Input @Optional final Property timeoutFactor @@ -261,6 +265,7 @@ class PitestTask extends JavaExec { excludedTestClasses = of.setProperty(String) avoidCallsTo = of.setProperty(String) verbose = of.property(Boolean) + verbosity = of.property(String) timeoutFactor = of.property(BigDecimal) timeoutConstInMillis = of.property(Integer) childProcessJvmArgs = of.listProperty(String) @@ -350,6 +355,7 @@ class PitestTask extends JavaExec { map['excludedTestClasses'] = optionalCollectionAsString(excludedTestClasses) map['avoidCallsTo'] = optionalCollectionAsString(avoidCallsTo) map['verbose'] = optionalPropertyAsString(verbose) + map['verbosity'] = optionalPropertyAsString(verbosity) map['timeoutFactor'] = optionalPropertyAsString(timeoutFactor) map['timeoutConst'] = optionalPropertyAsString(timeoutConstInMillis) map['jvmArgs'] = optionalCollectionAsString(childProcessJvmArgs) diff --git a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy index 670b641c..c15e004c 100644 --- a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy +++ b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy @@ -124,6 +124,19 @@ class PitestTaskConfigurationSpec extends BasicProjectBuilderSpec implements Wit paramName << PIT_PARAMETERS_NAMES_NOT_SET_BY_DEFAULT } + void "should pass to PIT parameter 'verbosity' by default if not set explicitly"() { + expect: + task.taskArgumentMap().containsKey('verbosity') + task.taskArgumentMap().get('verbosity').is('NO_SPINNER') + } + + void "should pass to PIT parameter 'verbosity' if set explicitly"() { + given: + project.pitest.verbosity = 'QUIET_WITH_PROGRESS' + expect: + task.taskArgumentMap().get('verbosity').is('QUIET_WITH_PROGRESS') + } + //TODO: Run PIT with those values to detect removed properties and typos void "should pass plugin configuration (#configParamName) from Gradle to PIT"() { given: From 8b001f7a2d6120d83e137d439195d1976d7d97ed Mon Sep 17 00:00:00 2001 From: Carsten Otto Date: Fri, 18 Nov 2022 08:00:59 +0100 Subject: [PATCH 29/60] require version 1.7.1+, update readme --- README.md | 22 +++++++++---------- ...itestPluginPitVersionFunctionalSpec.groovy | 10 ++------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 22c7caef..e0cf4bde 100644 --- a/README.md +++ b/README.md @@ -77,14 +77,14 @@ pitest { The configuration in Gradle is the real Groovy code which makes all assignments very intuitive. All values expected by PIT should be passed as a corresponding types. There is only one important difference. For the parameters where PIT expects a coma separated list of strings in a Gradle configuration a list of strings should be used (see `outputFormats` in the -following example). +example above). Check PIT documentation for a [list](https://pitest.org/quickstart/commandline/) of all available command line parameters. The expected parameter format in a plugin configuration can be taken from [PitestPluginExtension](https://github.com/szpak/gradle-pitest-plugin/blob/master/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy). -To make life easier `taskClasspath`, `mutableCodePaths`, `sourceDirs`, `reportDir` and `pitestVersion` are -automatically set by a plugin. In addition `sourceDirs`, `reportDir` and `pitestVersion` can be overridden by a user. +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. There are a few parameters specific for Gradle plugin: @@ -113,7 +113,7 @@ pitest { ### Test system properties -PIT executes tests in a JVM independent from the JVM used by Gradle to execute tests. If your tests require some system properties, you have to pass them to PIT as the plugin won't do it for you: +PIT executes tests in a JVM independent of the JVM used by Gradle to execute tests. If your tests require some system properties, you have to pass them to PIT as the plugin won't do it for you: ```groovy test { @@ -127,7 +127,7 @@ pitest { ### Eliminate warning in Idea -As reported in [#170](https://github.com/szpak/gradle-pitest-plugin/pull/170) Idea displays warnings about setting final fields (of [lazy configuration](https://docs.gradle.org/current/userguide/lazy_configuration.html)) in `build.gradle`. It is not a real problem as Gradle internally intercepts those calls and use a setter instead . Nevertheless, people which prefer to have no (less) warnings at the cost of less readable code can use setters instead, e.g: +As reported in [#170](https://github.com/szpak/gradle-pitest-plugin/pull/170) IntelliJ IDEA displays warnings about setting final fields (of [lazy configuration](https://docs.gradle.org/current/userguide/lazy_configuration.html)) in `build.gradle`. It is not a real problem as Gradle internally intercepts those calls and use a setter instead . Nevertheless, people which prefer to have no (less) warnings at the cost of less readable code can use setters instead, e.g: ```groovy testSourceSets.set([sourceSets.test, sourceSets.integrationTest]) @@ -287,7 +287,7 @@ Please note. Starting with PIT 1.6.7 it is no longer needed to set `testPlugin` ## Versions -Every gradle-pitest-plugin version by default uses a predefined PIT version. Usually this a the latest released version +Every gradle-pitest-plugin version by default uses a predefined PIT version. Usually this the latest released version of PIT available at the time of releasing a plugin version. It can be overridden by using `pitestVersion` parameter in a `pitest` configuration closure. @@ -318,16 +318,16 @@ After [applied](https://github.com/nebula-plugins/gradle-override-plugin) gradle ./gradlew pitest -Doverride.pitest.reportDir=build/pitReport -Doverride.pitest.threads=8 -Note. The mechanism should work fine for String and numeric properties, but the are limitations with support of +Note. The mechanism should work fine for String and numeric properties, but there are limitations with support of [Lists/Sets/Maps](https://github.com/nebula-plugins/gradle-override-plugin/issues/3) and [Boolean values](https://github.com/nebula-plugins/gradle-override-plugin/issues/1). For more information see project [web page](https://github.com/nebula-plugins/gradle-override-plugin). ### How can I change PIT version from default to just released the newest one? -gradle-pitest-plugin by default uses a corresponsing PIT version (with the same number). The plugin is released only if there are internal changes or +gradle-pitest-plugin by default uses a corresponding PIT version (with the same number). The plugin is released only if there are internal changes or there is a need to adjust to changes in newer PIT version. There is a dedicated mechanism to allow to use the latest PIT version (e.g, a bugfix release) -or to downgrade PIT in case of detected issues. To override a defalt version it is enough to set `pitestVersion` property in the `pitest` configuration +or to downgrade PIT in case of detected issues. To override a default version it is enough to set `pitestVersion` property in the `pitest` configuration closure. ```groovy @@ -350,7 +350,7 @@ pitest { ### How can I debug a gradle-pitest-plugin execution or a PIT process execution itself in a Gradle build? -Ocasionally, it may be useful to debug a gradle-pitest-plugin execution or a PIT execution itself (e.g. [NPE in PIT](https://github.com/hcoles/pitest/issues/345)) to provide sensible error report. +Occasionally, it may be useful to debug a gradle-pitest-plugin execution or a PIT execution itself (e.g. [NPE in PIT](https://github.com/hcoles/pitest/issues/345)) to provide sensible error report. The gradle-pitest-plugin execution can be remotely debugged with adding `-Dorg.gradle.debug=true` to the command line. @@ -375,7 +375,7 @@ gradle-pitest plugin [1.5.0](https://github.com/szpak/gradle-pitest-plugin/relea ## Known issues - - too verbose output from PIT + - too verbose output from PIT (also see `verbosity` option introduced with PIT 1.7.1) ## Development diff --git a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginPitVersionFunctionalSpec.groovy b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginPitVersionFunctionalSpec.groovy index 9ac192d5..6d0f8531 100644 --- a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginPitVersionFunctionalSpec.groovy +++ b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginPitVersionFunctionalSpec.groovy @@ -3,14 +3,12 @@ package info.solidsoft.gradle.pitest.functional import groovy.transform.CompileDynamic import info.solidsoft.gradle.pitest.PitestPlugin import nebula.test.functional.ExecutionResult -import org.gradle.internal.jvm.Jvm @SuppressWarnings("GrMethodMayBeStatic") @CompileDynamic class PitestPluginPitVersionFunctionalSpec extends AbstractPitestFunctionalSpec { - private static final String MINIMAL_SUPPORTED_PIT_VERSION = "1.4.1" //minimal PIT version that works with Java 11 - Aug 2018 - private static final String MINIMAL_JAVA17_COMPATIBLE_PIT_VERSION = "1.6.8" + private static final String MINIMAL_SUPPORTED_PIT_VERSION = "1.7.1" //minimal PIT version that includes verbosity flag - Sep 2021 void "setup and run pitest task with PIT #pitVersion"() { given: @@ -45,11 +43,7 @@ class PitestPluginPitVersionFunctionalSpec extends AbstractPitestFunctionalSpec } private String getMinimalPitVersionCompatibleWithCurrentJavaVersion() { - if (Jvm.current().javaVersion.isJava12Compatible()) { - return MINIMAL_JAVA17_COMPATIBLE_PIT_VERSION //safe modern version - } else { - return MINIMAL_SUPPORTED_PIT_VERSION //minimal supported PIT version only for testing with Java <12, due to JVM compatibility issues - } + return MINIMAL_SUPPORTED_PIT_VERSION } } From 20a35269ac7ea41eae26213efceae31cafceaf96 Mon Sep 17 00:00:00 2001 From: Carsten Otto Date: Fri, 18 Nov 2022 08:21:14 +0100 Subject: [PATCH 30/60] add Javadoc for verbose/verbosity --- .../pitest/PitestPluginExtension.groovy | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy index 40a20980..5cd0fefa 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy @@ -89,8 +89,32 @@ class PitestPluginExtension { @Incubating final SetProperty excludedTestClasses final SetProperty avoidCallsTo + /** + *

If true, verbose logging is enabled (capture minion output, show the spinner, only log at detailed level).

+ *

If false, the value of verbosity is used to determine the verbosity of the output.

+ *

Disabled by default.

+ * + * @see #verbosity + */ final Property verbose - final Property verbosity + + /** + * Determines the verbosity of the output. Possible values: + *
    + *
  • QUIET (no capture of minion output, no spinner, only log severe errors)
  • + *
  • QUIET_WITH_PROGRESS (no capture of minion output, show the spinner, only log severe errors)
  • + *
  • DEFAULT (no capture of minion output, show the spinner, only log at info level)
  • + *
  • NO_SPINNER (no capture of minion output, no spinner, only log at info level)
  • + *
  • VERBOSE_NO_SPINNER (capture minion output, no spinner, only log at detailed level)
  • + *
  • VERBOSE (capture minion output, show the spinner, only log at detailed level)
  • + *
+ *

The default value used by the plugin is NO_SPINNER (not DEFAULT, despite the name).

+ *

Note: verbose must be set to false (which is the default) for this to have an effect.

+ * + * @see #verbose + * @since 1.9.1 + */ + final Property verbosity //new in PIT 1.7.1 (GPP 1.9.1) final Property timeoutFactor final Property timeoutConstInMillis /** From 7e75d1a17af764857c81e7e7b47055bef07ec0ed Mon Sep 17 00:00:00 2001 From: fesc7420 <17569373+Pfoerd@users.noreply.github.com> Date: Wed, 16 Nov 2022 17:33:29 +0100 Subject: [PATCH 31/60] [#319] Add support for thresholds of aggregated metrics on-behalf-of: @e-solutions-GmbH --- build.gradle | 2 +- ...sInSeparateSubprojectFunctionalSpec.groovy | 2 ++ .../multiproject/build-report.gradle | 5 +++ .../pitest/AggregateReportGenerator.groovy | 31 ++++++++++++++++++- .../gradle/pitest/AggregateReportTask.groovy | 18 +++++++++++ .../AggregateReportWorkParameters.groovy | 3 ++ .../pitest/PitestAggregatorPlugin.groovy | 3 ++ .../gradle/pitest/PitestPlugin.groovy | 2 +- .../pitest/PitestPluginExtension.groovy | 8 +++++ .../pitest/ReportAggregatorProperties.groovy | 23 ++++++++++++++ 10 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 src/main/groovy/info/solidsoft/gradle/pitest/ReportAggregatorProperties.groovy diff --git a/build.gradle b/build.gradle index c104c063..b42189e5 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ buildscript { sourceCompatibility = 1.8 -ext.pitestAggregatorVersion = "1.9.4" //Must be equal to default PIT version in PitestPlugin +ext.pitestAggregatorVersion = "1.9.10" //Must be equal to default PIT version in PitestPlugin repositories { mavenCentral() diff --git a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/AcceptanceTestsInSeparateSubprojectFunctionalSpec.groovy b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/AcceptanceTestsInSeparateSubprojectFunctionalSpec.groovy index 79644030..8a590c86 100644 --- a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/AcceptanceTestsInSeparateSubprojectFunctionalSpec.groovy +++ b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/AcceptanceTestsInSeparateSubprojectFunctionalSpec.groovy @@ -44,9 +44,11 @@ class AcceptanceTestsInSeparateSubprojectFunctionalSpec extends AbstractPitestFu assertHtmlContains("Number of Classes") assertHtmlContains("Line Coverage") assertHtmlContains("Mutation Coverage") + assertHtmlContains("Test Strength") assertHtmlContains("2") assertHtmlContains("95% ") assertHtmlContains("40% ") + assertHtmlContains("50% ") assertHtmlContains("pitest.sample.multimodule.forreport") assertHtmlContains("pitest.sample.multimodule.shared") } diff --git a/src/funcTest/resources/testProjects/multiproject/build-report.gradle b/src/funcTest/resources/testProjects/multiproject/build-report.gradle index 13587f40..cde852d4 100644 --- a/src/funcTest/resources/testProjects/multiproject/build-report.gradle +++ b/src/funcTest/resources/testProjects/multiproject/build-report.gradle @@ -42,6 +42,11 @@ subprojects { outputFormats = ["HTML","XML"] timestampedReports = false exportLineCoverage = true + reportAggregator { + aggregatedTestStrengthThreshold.set(50) + aggregatedMutationThreshold.set(40) + aggregatedMaxSurviving.set(3) + } } } } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportGenerator.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportGenerator.groovy index f3e265c6..c3e04bcf 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportGenerator.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportGenerator.groovy @@ -2,9 +2,11 @@ package info.solidsoft.gradle.pitest import groovy.transform.CompileStatic import groovy.util.logging.Slf4j +import org.gradle.api.GradleException import org.gradle.api.Incubating import org.gradle.api.provider.Property import org.gradle.workers.WorkAction +import org.pitest.aggregate.AggregationResult import org.pitest.aggregate.ReportAggregator import org.pitest.mutationtest.config.DirectoryResultOutputStrategy import org.pitest.mutationtest.config.UndatedReportDirCreationStrategy @@ -33,9 +35,36 @@ abstract class AggregateReportGenerator implements WorkAction + if (aggregationResult.testStrength < threshold) { + throw new GradleException( + "Aggregated test strength score of ${aggregationResult.testStrength} " + + "is below threshold of $threshold" + ) + } + } + + consumeIfPropertyIsSet(parameters.aggregatedMutationThreshold) { threshold -> + if (aggregationResult.mutationCoverage < threshold) { + throw new GradleException( + "Aggregated mutation score of ${aggregationResult.mutationCoverage} " + + "is below threshold of $threshold" + ) + } + } + + consumeIfPropertyIsSet(parameters.aggregatedMaxSurviving) { threshold -> + if (aggregationResult.mutationsSurvived > threshold) { + throw new GradleException( + "Had ${aggregationResult.mutationsSurvived} " + + "surviving mutants, but only $threshold survivors allowed" + ) + } + } } private static void consumeIfPropertyIsSet(Property property, Consumer applyPropertyCode) { diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy index 743ea88d..caf06522 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy @@ -72,6 +72,18 @@ abstract class AggregateReportTask extends DefaultTask { @Optional final Property outputCharset + @Input + @Optional + final Property aggregatedTestStrengthThreshold + + @Input + @Optional + final Property aggregatedMutationThreshold + + @Input + @Optional + final Property aggregatedMaxSurviving + @Inject abstract WorkerExecutor getWorkerExecutor() @@ -85,6 +97,9 @@ abstract class AggregateReportTask extends DefaultTask { lineCoverageFiles = of.fileCollection() inputCharset = of.property(Charset) outputCharset = of.property(Charset) + aggregatedTestStrengthThreshold = of.property(Integer) + aggregatedMutationThreshold = of.property(Integer) + aggregatedMaxSurviving = of.property(Integer) } @TaskAction @@ -103,6 +118,9 @@ abstract class AggregateReportTask extends DefaultTask { parameters.lineCoverageFiles.from(lineCoverageFiles) parameters.inputCharset.set(this.inputCharset) parameters.outputCharset.set(this.outputCharset) + parameters.aggregatedTestStrengthThreshold.set(this.aggregatedTestStrengthThreshold) + parameters.aggregatedMutationThreshold.set(this.aggregatedMutationThreshold) + parameters.aggregatedMaxSurviving.set(this.aggregatedMaxSurviving) } } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportWorkParameters.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportWorkParameters.groovy index 2a44119d..dead7ad1 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportWorkParameters.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportWorkParameters.groovy @@ -20,5 +20,8 @@ interface AggregateReportWorkParameters extends WorkParameters { ConfigurableFileCollection getLineCoverageFiles() Property getInputCharset() Property getOutputCharset() + Property getAggregatedTestStrengthThreshold() + Property getAggregatedMutationThreshold() + Property getAggregatedMaxSurviving() } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy index 67bc8b00..76e7c7b8 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy @@ -80,6 +80,9 @@ class PitestAggregatorPlugin implements Plugin { findPluginExtension().ifPresent({ PitestPluginExtension extension -> inputCharset.set(extension.inputCharset) outputCharset.set(extension.outputCharset) + aggregatedTestStrengthThreshold.set(extension.reportAggregatorProperties.aggregatedTestStrengthThreshold) + aggregatedMutationThreshold.set(extension.reportAggregatorProperties.aggregatedMutationThreshold) + aggregatedMaxSurviving.set(extension.reportAggregatorProperties.aggregatedMaxSurviving) } as Consumer) //Simplify with Groovy 3+ } } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index 7b23330c..972ea50c 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -52,7 +52,7 @@ class PitestPlugin implements Plugin { public final static String PITEST_REPORT_DIRECTORY_NAME = 'pitest' public final static String PITEST_CONFIGURATION_NAME = 'pitest' - public final static String DEFAULT_PITEST_VERSION = '1.9.4' + public final static String DEFAULT_PITEST_VERSION = '1.9.10' @Internal //6.4 due to main -> mainClass change to avoid deprecation warning in Gradle 7.x - https://github.com/szpak/gradle-pitest-plugin/pull/289 public static final GradleVersion MINIMAL_SUPPORTED_GRADLE_VERSION = GradleVersion.version("6.4") //public as used also in regression tests diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy index 722398c4..760333a2 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy @@ -16,6 +16,7 @@ package info.solidsoft.gradle.pitest import groovy.transform.CompileStatic +import org.gradle.api.Action import org.gradle.api.Incubating import org.gradle.api.Project import org.gradle.api.file.DirectoryProperty @@ -220,6 +221,8 @@ class PitestPluginExtension { @Incubating final ListProperty fileExtensionsToFilter + final ReportAggregatorProperties reportAggregatorProperties + PitestPluginExtension(Project project) { ObjectFactory of = project.objects Project p = project @@ -270,6 +273,11 @@ class PitestPluginExtension { outputCharset = of.property(Charset) features = nullListPropertyOf(p, String) fileExtensionsToFilter = nullListPropertyOf(p, String) + reportAggregatorProperties = new ReportAggregatorProperties(of) + } + + void reportAggregator(Action action) { + action.execute(reportAggregatorProperties) } void setReportDir(File reportDir) { diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/ReportAggregatorProperties.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/ReportAggregatorProperties.groovy new file mode 100644 index 00000000..0234027e --- /dev/null +++ b/src/main/groovy/info/solidsoft/gradle/pitest/ReportAggregatorProperties.groovy @@ -0,0 +1,23 @@ +package info.solidsoft.gradle.pitest + +import groovy.transform.CompileStatic +import org.gradle.api.model.ObjectFactory +import org.gradle.api.provider.Property + +import javax.inject.Inject + +@CompileStatic +class ReportAggregatorProperties { + + final Property aggregatedTestStrengthThreshold + final Property aggregatedMutationThreshold + final Property aggregatedMaxSurviving + + @Inject + ReportAggregatorProperties(ObjectFactory objects) { + aggregatedTestStrengthThreshold = objects.property(Integer) + aggregatedMutationThreshold = objects.property(Integer) + aggregatedMaxSurviving = objects.property(Integer) + } + +} From fd89538dd03d9e2c1994c2a82b428063fc171462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 25 Nov 2022 22:55:58 +0100 Subject: [PATCH 32/60] [#267] Minor documentation update --- CHANGELOG.md | 9 +++++++++ README.md | 2 +- .../PitestPluginPitVersionFunctionalSpec.groovy | 6 +----- .../solidsoft/gradle/pitest/PitestPluginExtension.groovy | 8 ++++++-- .../gradle/pitest/PitestTaskConfigurationSpec.groovy | 8 ++++---- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5276b27..71c1a39d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # gradle-pitest-plugin changelog +## 1.9.11 - Unreleased + + - Support for `verbosity` flag, "spinner" disabled by default - [#267](https://github.com/szpak/gradle-pitest-plugin/issues/267) + - Minimal supported PIT version is 1.7.1 (due to "verbosity" flag used by default) + - Deprecated `verbose` flag - `verbosity` is much more versatile, especially when used from the Gradle plugin + +**Compatibility notes**. Due to the usage of the "verbosity" flag by default, the minimal supported PIT version is 1.7.1 (released 2021-09-29) + + ## 1.9.0 - 2022-08-19 - PIT 1.9.4 by default (requires pitest-junit5-plugin 1.0.0!) diff --git a/README.md b/README.md index e0cf4bde..1ceed83b 100644 --- a/README.md +++ b/README.md @@ -293,7 +293,7 @@ in a `pitest` configuration closure. Please be aware that in some cases there could be some issues when using non default PIT versions. -If not stated otherwise, gradle-pitest-plugin 1.9.x by default uses PIT 1.9.x, 1.7.x uses PIT 1.7.x, etc. +If not stated otherwise, gradle-pitest-plugin 1.9.x by default uses PIT 1.9.x, 1.7.x uses PIT 1.7.x, etc. The minimal supported PIT version is 1.7.1. Starting with version 1.7.0 gradle-pitest-plugin requires Gradle 6.4. The latest version with the Gradle 5.x (5.6+) support is 1.6.0. The current version was automatically smoke tested with Gradle 6.4, 6.9.1 and 7.4.2 under Java 11. diff --git a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginPitVersionFunctionalSpec.groovy b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginPitVersionFunctionalSpec.groovy index 6d0f8531..fe162514 100644 --- a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginPitVersionFunctionalSpec.groovy +++ b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginPitVersionFunctionalSpec.groovy @@ -39,11 +39,7 @@ class PitestPluginPitVersionFunctionalSpec extends AbstractPitestFunctionalSpec } private List getPitVersionsCompatibleWithCurrentJavaVersion() { - return [getMinimalPitVersionCompatibleWithCurrentJavaVersion(), PitestPlugin.DEFAULT_PITEST_VERSION] - } - - private String getMinimalPitVersionCompatibleWithCurrentJavaVersion() { - return MINIMAL_SUPPORTED_PIT_VERSION + return [MINIMAL_SUPPORTED_PIT_VERSION, PitestPlugin.DEFAULT_PITEST_VERSION] } } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy index 5cd0fefa..7982d492 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy @@ -94,8 +94,12 @@ class PitestPluginExtension { *

If false, the value of verbosity is used to determine the verbosity of the output.

*

Disabled by default.

* + *

Note: This property is marked as deprecated as - in the majority of cases - it doesn't make sense to use it, if PIT is called using the Gradle + * plugin. Use #verosity instead.

+ * * @see #verbosity */ + @Deprecated //since GPP 1.9.11 final Property verbose /** @@ -112,9 +116,9 @@ class PitestPluginExtension { *

Note: verbose must be set to false (which is the default) for this to have an effect.

* * @see #verbose - * @since 1.9.1 + * @since 1.9.11 */ - final Property verbosity //new in PIT 1.7.1 (GPP 1.9.1) + final Property verbosity //new in PIT 1.7.1 (GPP 1.9.11) final Property timeoutFactor final Property timeoutConstInMillis /** diff --git a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy index c15e004c..8ed5ee38 100644 --- a/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy +++ b/src/test/groovy/info/solidsoft/gradle/pitest/PitestTaskConfigurationSpec.groovy @@ -126,15 +126,15 @@ class PitestTaskConfigurationSpec extends BasicProjectBuilderSpec implements Wit void "should pass to PIT parameter 'verbosity' by default if not set explicitly"() { expect: - task.taskArgumentMap().containsKey('verbosity') - task.taskArgumentMap().get('verbosity').is('NO_SPINNER') + task.taskArgumentMap().containsKey('verbosity') + task.taskArgumentMap().get('verbosity').is('NO_SPINNER') } void "should pass to PIT parameter 'verbosity' if set explicitly"() { given: - project.pitest.verbosity = 'QUIET_WITH_PROGRESS' + project.pitest.verbosity = 'QUIET_WITH_PROGRESS' expect: - task.taskArgumentMap().get('verbosity').is('QUIET_WITH_PROGRESS') + task.taskArgumentMap().get('verbosity').is('QUIET_WITH_PROGRESS') } //TODO: Run PIT with those values to detect removed properties and typos From d8a9b9729cc19c41cdc23e870ca4ba636a5711b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 25 Nov 2022 23:23:17 +0100 Subject: [PATCH 33/60] [#319] Tweak nested property names for aggregated thresholds Also updated CHANGELOG and README. --- CHANGELOG.md | 4 +++- README.md | 5 +++++ .../multiproject/build-report.gradle | 6 +++--- .../pitest/AggregateReportGenerator.groovy | 6 +++--- .../gradle/pitest/AggregateReportTask.groovy | 18 +++++++++--------- .../AggregateReportWorkParameters.groovy | 6 +++--- .../pitest/PitestAggregatorPlugin.groovy | 6 +++--- .../pitest/ReportAggregatorProperties.groovy | 12 ++++++------ 8 files changed, 35 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71c1a39d..7500b3de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,9 @@ ## 1.9.11 - Unreleased - - Support for `verbosity` flag, "spinner" disabled by default - [#267](https://github.com/szpak/gradle-pitest-plugin/issues/267) + - Support for thresholds in aggregated metrics (requires PIT 1.9.9+) - [#319](https://github.com/szpak/gradle-pitest-plugin/issues/319) - PR by [pfoerd](https://github.com/Pfoerd) + - Support for `verbosity` flag, "spinner" disabled by default - [#267](https://github.com/szpak/gradle-pitest-plugin/issues/267) - PR by [Carsten Otto](https://github.com/C-Otto) + - PIT 1.9.10 by default - Minimal supported PIT version is 1.7.1 (due to "verbosity" flag used by default) - Deprecated `verbose` flag - `verbosity` is much more versatile, especially when used from the Gradle plugin diff --git a/README.md b/README.md index 1ceed83b..1e04b599 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,11 @@ subprojects { exportLineCoverage = true timestampedReports = false ... + reportAggregator { //since 1.9.11 - extra results validation, if needed + testStrengthThreshold.set(50) //simpler Groovy syntax (testStrengthThreshold = 50) does not seem to be supported for nested properties + mutationThreshold.set(40) + maxSurviving.set(3) + } } } ``` diff --git a/src/funcTest/resources/testProjects/multiproject/build-report.gradle b/src/funcTest/resources/testProjects/multiproject/build-report.gradle index cde852d4..6cf81f33 100644 --- a/src/funcTest/resources/testProjects/multiproject/build-report.gradle +++ b/src/funcTest/resources/testProjects/multiproject/build-report.gradle @@ -43,9 +43,9 @@ subprojects { timestampedReports = false exportLineCoverage = true reportAggregator { - aggregatedTestStrengthThreshold.set(50) - aggregatedMutationThreshold.set(40) - aggregatedMaxSurviving.set(3) + testStrengthThreshold.set(50) //simpler Groovy syntax (testStrengthThreshold = 50) does not seem to be supported for nested properties + mutationThreshold.set(40) + maxSurviving.set(3) } } } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportGenerator.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportGenerator.groovy index c3e04bcf..79be3169 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportGenerator.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportGenerator.groovy @@ -39,7 +39,7 @@ abstract class AggregateReportGenerator implements WorkAction + consumeIfPropertyIsSet(parameters.testStrengthThreshold) { threshold -> if (aggregationResult.testStrength < threshold) { throw new GradleException( "Aggregated test strength score of ${aggregationResult.testStrength} " + @@ -48,7 +48,7 @@ abstract class AggregateReportGenerator implements WorkAction + consumeIfPropertyIsSet(parameters.mutationThreshold) { threshold -> if (aggregationResult.mutationCoverage < threshold) { throw new GradleException( "Aggregated mutation score of ${aggregationResult.mutationCoverage} " + @@ -57,7 +57,7 @@ abstract class AggregateReportGenerator implements WorkAction + consumeIfPropertyIsSet(parameters.maxSurviving) { threshold -> if (aggregationResult.mutationsSurvived > threshold) { throw new GradleException( "Had ${aggregationResult.mutationsSurvived} " + diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy index caf06522..2c1811f7 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy @@ -74,15 +74,15 @@ abstract class AggregateReportTask extends DefaultTask { @Input @Optional - final Property aggregatedTestStrengthThreshold + final Property testStrengthThreshold @Input @Optional - final Property aggregatedMutationThreshold + final Property mutationThreshold @Input @Optional - final Property aggregatedMaxSurviving + final Property maxSurviving @Inject abstract WorkerExecutor getWorkerExecutor() @@ -97,9 +97,9 @@ abstract class AggregateReportTask extends DefaultTask { lineCoverageFiles = of.fileCollection() inputCharset = of.property(Charset) outputCharset = of.property(Charset) - aggregatedTestStrengthThreshold = of.property(Integer) - aggregatedMutationThreshold = of.property(Integer) - aggregatedMaxSurviving = of.property(Integer) + testStrengthThreshold = of.property(Integer) + mutationThreshold = of.property(Integer) + maxSurviving = of.property(Integer) } @TaskAction @@ -118,9 +118,9 @@ abstract class AggregateReportTask extends DefaultTask { parameters.lineCoverageFiles.from(lineCoverageFiles) parameters.inputCharset.set(this.inputCharset) parameters.outputCharset.set(this.outputCharset) - parameters.aggregatedTestStrengthThreshold.set(this.aggregatedTestStrengthThreshold) - parameters.aggregatedMutationThreshold.set(this.aggregatedMutationThreshold) - parameters.aggregatedMaxSurviving.set(this.aggregatedMaxSurviving) + parameters.testStrengthThreshold.set(this.testStrengthThreshold) + parameters.mutationThreshold.set(this.mutationThreshold) + parameters.maxSurviving.set(this.maxSurviving) } } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportWorkParameters.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportWorkParameters.groovy index dead7ad1..71dd98e0 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportWorkParameters.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportWorkParameters.groovy @@ -20,8 +20,8 @@ interface AggregateReportWorkParameters extends WorkParameters { ConfigurableFileCollection getLineCoverageFiles() Property getInputCharset() Property getOutputCharset() - Property getAggregatedTestStrengthThreshold() - Property getAggregatedMutationThreshold() - Property getAggregatedMaxSurviving() + Property getTestStrengthThreshold() + Property getMutationThreshold() + Property getMaxSurviving() } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy index 76e7c7b8..43fc8061 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestAggregatorPlugin.groovy @@ -80,9 +80,9 @@ class PitestAggregatorPlugin implements Plugin { findPluginExtension().ifPresent({ PitestPluginExtension extension -> inputCharset.set(extension.inputCharset) outputCharset.set(extension.outputCharset) - aggregatedTestStrengthThreshold.set(extension.reportAggregatorProperties.aggregatedTestStrengthThreshold) - aggregatedMutationThreshold.set(extension.reportAggregatorProperties.aggregatedMutationThreshold) - aggregatedMaxSurviving.set(extension.reportAggregatorProperties.aggregatedMaxSurviving) + testStrengthThreshold.set(extension.reportAggregatorProperties.testStrengthThreshold) + mutationThreshold.set(extension.reportAggregatorProperties.mutationThreshold) + maxSurviving.set(extension.reportAggregatorProperties.maxSurviving) } as Consumer) //Simplify with Groovy 3+ } } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/ReportAggregatorProperties.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/ReportAggregatorProperties.groovy index 0234027e..176fef46 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/ReportAggregatorProperties.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/ReportAggregatorProperties.groovy @@ -9,15 +9,15 @@ import javax.inject.Inject @CompileStatic class ReportAggregatorProperties { - final Property aggregatedTestStrengthThreshold - final Property aggregatedMutationThreshold - final Property aggregatedMaxSurviving + final Property testStrengthThreshold + final Property mutationThreshold + final Property maxSurviving @Inject ReportAggregatorProperties(ObjectFactory objects) { - aggregatedTestStrengthThreshold = objects.property(Integer) - aggregatedMutationThreshold = objects.property(Integer) - aggregatedMaxSurviving = objects.property(Integer) + testStrengthThreshold = objects.property(Integer) + mutationThreshold = objects.property(Integer) + maxSurviving = objects.property(Integer) } } From 80cd78f30c5cddaf06e0ba8d9f0dd28a74f6a94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 25 Nov 2022 23:24:14 +0100 Subject: [PATCH 34/60] PIT 1.9.11 by default --- CHANGELOG.md | 2 +- build.gradle | 2 +- .../groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7500b3de..221bef4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - Support for thresholds in aggregated metrics (requires PIT 1.9.9+) - [#319](https://github.com/szpak/gradle-pitest-plugin/issues/319) - PR by [pfoerd](https://github.com/Pfoerd) - Support for `verbosity` flag, "spinner" disabled by default - [#267](https://github.com/szpak/gradle-pitest-plugin/issues/267) - PR by [Carsten Otto](https://github.com/C-Otto) - - PIT 1.9.10 by default + - PIT 1.9.11 by default - Minimal supported PIT version is 1.7.1 (due to "verbosity" flag used by default) - Deprecated `verbose` flag - `verbosity` is much more versatile, especially when used from the Gradle plugin diff --git a/build.gradle b/build.gradle index b42189e5..83be858c 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ buildscript { sourceCompatibility = 1.8 -ext.pitestAggregatorVersion = "1.9.10" //Must be equal to default PIT version in PitestPlugin +ext.pitestAggregatorVersion = "1.9.11" //Must be equal to default PIT version in PitestPlugin repositories { mavenCentral() diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index 9439084f..fa9a49f5 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -52,7 +52,7 @@ class PitestPlugin implements Plugin { public final static String PITEST_REPORT_DIRECTORY_NAME = 'pitest' public final static String PITEST_CONFIGURATION_NAME = 'pitest' - public final static String DEFAULT_PITEST_VERSION = '1.9.10' + public final static String DEFAULT_PITEST_VERSION = '1.9.11' @Internal //6.4 due to main -> mainClass change to avoid deprecation warning in Gradle 7.x - https://github.com/szpak/gradle-pitest-plugin/pull/289 public static final GradleVersion MINIMAL_SUPPORTED_GRADLE_VERSION = GradleVersion.version("6.4") //public as used also in regression tests From b8fe56c80a6bab2f861d3a999a33fc820e04c25b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 25 Nov 2022 23:26:04 +0100 Subject: [PATCH 35/60] Bump maximum Gradle version in regression tests to 7.6 --- .../PitestPluginGradleVersionFunctionalSpec.groovy | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy index e08c4e11..35dcc89e 100644 --- a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy +++ b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy @@ -31,7 +31,7 @@ import static info.solidsoft.gradle.pitest.PitestTaskConfigurationSpec.PIT_PARAM @CompileDynamic class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSpec { - private static final GradleVersion LATEST_KNOWN_GRADLE_VERSION = GradleVersion.version("7.5.1") + private static final GradleVersion LATEST_KNOWN_GRADLE_VERSION = GradleVersion.version("7.6") //Baased on https://docs.gradle.org/current/userguide/compatibility.html private static final Map MINIMAL_GRADLE_VERSION_FOR_JAVA_VERSION = [ @@ -102,10 +102,11 @@ class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSp private static final String REGRESSION_TESTS_ENV_NAME = "PITEST_REGRESSION_TESTS" private static final List GRADLE6_VERSIONS = ["6.9.2", "6.8.3", "6.7", "6.6", "6.5", PitestPlugin.MINIMAL_SUPPORTED_GRADLE_VERSION.version] - private static final List GRADLE7_VERSIONS = [LATEST_KNOWN_GRADLE_VERSION.version, "7.4.1", "7.3.3", "7.2", "7.1.1", "7.0.2"] + private static final List GRADLE7_VERSIONS = [LATEST_KNOWN_GRADLE_VERSION.version, "7.5.1", "7.4.1", "7.3.3", "7.2", "7.1.1", "7.0.2"] private static final List GRADLE_LATEST_VERSIONS = [GRADLE6_VERSIONS.first(), GRADLE7_VERSIONS.first(), PitestPlugin.MINIMAL_SUPPORTED_GRADLE_VERSION.version] + @SuppressWarnings('GroovyFallthrough') private List resolveRequestedGradleVersions() { String regressionTestsLevel = System.getenv(REGRESSION_TESTS_ENV_NAME) log.debug("$REGRESSION_TESTS_ENV_NAME set to '${regressionTestsLevel}'") From 598b8d1e4165a25a143aa1cd6b28aed55a946421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 25 Nov 2022 23:28:46 +0100 Subject: [PATCH 36/60] Bump Spock and ByteBuddy test dependencies --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 83be858c..dee5f9b3 100644 --- a/build.gradle +++ b/build.gradle @@ -39,14 +39,14 @@ dependencies { implementation localGroovy() compileOnly "org.pitest:pitest-aggregator:$pitestAggregatorVersion" - testImplementation('org.spockframework:spock-core:2.2-M3-groovy-2.5') { + testImplementation('org.spockframework:spock-core:2.3-groovy-2.5') { exclude group: 'org.codehaus.groovy' } //for "@Rule TemporaryFolder" - testImplementation('org.spockframework:spock-junit4:2.2-M3-groovy-2.5') { + testImplementation('org.spockframework:spock-junit4:2.3-groovy-2.5') { exclude group: 'org.codehaus.groovy' } - testImplementation 'net.bytebuddy:byte-buddy:1.11.16' //for Spying in Spock + testImplementation 'net.bytebuddy:byte-buddy:1.12.19' //for Spying in Spock funcTestImplementation sourceSets.main.output //to make production plugin classes visible in functional tests (it's not in testCompile configuration) funcTestImplementation sourceSets.test.output From abeb1d82f066f61c038a59e05e10e5b14d685a2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 25 Nov 2022 23:33:17 +0100 Subject: [PATCH 37/60] [#318] Mention timestamped reports not generated by default With PIT 1.9.6+. --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 221bef4e..23abbe33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,13 @@ - Support for thresholds in aggregated metrics (requires PIT 1.9.9+) - [#319](https://github.com/szpak/gradle-pitest-plugin/issues/319) - PR by [pfoerd](https://github.com/Pfoerd) - Support for `verbosity` flag, "spinner" disabled by default - [#267](https://github.com/szpak/gradle-pitest-plugin/issues/267) - PR by [Carsten Otto](https://github.com/C-Otto) - PIT 1.9.11 by default + - Do not produce timestamped reports by default for PIT 1.9.6+ - suggestion by [Siddardha Bezawada](https://github.com/SidB3) - Minimal supported PIT version is 1.7.1 (due to "verbosity" flag used by default) - - Deprecated `verbose` flag - `verbosity` is much more versatile, especially when used from the Gradle plugin + - Deprecate `verbose` flag - `verbosity` is much more versatile, especially when used from the Gradle plugin -**Compatibility notes**. Due to the usage of the "verbosity" flag by default, the minimal supported PIT version is 1.7.1 (released 2021-09-29) +**Compatibility notes** +1. Due to the usage of the "verbosity" flag by default, the minimal supported PIT version is 1.7.1 (released 2021-09-29). +2. Due to the changes in PIT 1.9.6, timestamped reported are not generated by default (with PIT 1.9.6+). It still can be enforced in the GPP configuration. ## 1.9.0 - 2022-08-19 From 9e3446801b9a91130d24ff9a6ad1d236d1388e5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Sun, 27 Nov 2022 23:48:37 +0100 Subject: [PATCH 38/60] Trigger release [#DO_RELEASE][#1.9.11] From dc804a7d61f059d1eecd6744dd7526edbcaf4e8c Mon Sep 17 00:00:00 2001 From: Szpak CI Bot Date: Sun, 27 Nov 2022 22:55:05 +0000 Subject: [PATCH 39/60] Release version: 1.9.11 [ci skip] Powered by CDeliveryBoy. --- CHANGELOG.md | 2 +- README.md | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23abbe33..eb6097b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # gradle-pitest-plugin changelog -## 1.9.11 - Unreleased +## 1.9.11 - 2022-11-27 - Support for thresholds in aggregated metrics (requires PIT 1.9.9+) - [#319](https://github.com/szpak/gradle-pitest-plugin/issues/319) - PR by [pfoerd](https://github.com/Pfoerd) - Support for `verbosity` flag, "spinner" disabled by default - [#267](https://github.com/szpak/gradle-pitest-plugin/issues/267) - PR by [Carsten Otto](https://github.com/C-Otto) diff --git a/README.md b/README.md index 1e04b599..f806c0a6 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Add gradle-pitest-plugin to the `plugins` configuration in your `build.gradle` f ```groovy plugins { - id 'info.solidsoft.pitest' version '1.9.0' + id 'info.solidsoft.pitest' version '1.9.11' } ``` @@ -47,7 +47,7 @@ buildscript { //maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { - classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.9.0' + classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.9.11' } } ``` @@ -67,7 +67,7 @@ The Pitest plugin does not need to be additionally configured if you use JUnit 4 ```groovy pitest { targetClasses = ['our.base.package.*'] //by default "${project.group}.*" - pitestVersion = '1.9.0' //not needed when a default PIT version should be used + pitestVersion = '1.9.11' //not needed when a default PIT version should be used threads = 4 outputFormats = ['XML', 'HTML'] timestampedReports = false @@ -148,7 +148,7 @@ all subprojects which should be processed with PIT. A sample snippet from build. ```groovy //in root project configuration plugins { - id 'info.solidsoft.pitest' version '1.9.0' apply false + id 'info.solidsoft.pitest' version '1.9.11' apply false } subprojects { @@ -171,7 +171,7 @@ task `pitestReportAggregate`. Root project must be properly configured to use `p ```groovy //in root project configuration plugins { - id 'info.solidsoft.pitest' version '1.9.0' apply false + id 'info.solidsoft.pitest' version '1.9.11' apply false } apply plugin: 'info.solidsoft.pitest.aggregator' // to 'pitestReportAggregate' appear @@ -250,7 +250,7 @@ Starting with this release the configuration required to use PIT with JUnit 5 ha ```groovy plugins { id 'java' - id 'info.solidsoft.pitest' version '1.9.0' + id 'info.solidsoft.pitest' version '1.9.11' } pitest { @@ -273,7 +273,7 @@ To enable PIT plugins, it is enough to add it to the pitest configuration in the ```groovy plugins { id 'java' - id 'info.solidsoft.pitest' version '1.9.0' + id 'info.solidsoft.pitest' version '1.9.11' } repositories { From 3a33f6e2ab69a313faca663bec2abdb9eb68152b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Mon, 28 Nov 2022 21:21:11 +0100 Subject: [PATCH 40/60] Fix typo --- .../info/solidsoft/gradle/pitest/PitestPluginExtension.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy index c8022633..48075706 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy @@ -96,7 +96,7 @@ class PitestPluginExtension { *

Disabled by default.

* *

Note: This property is marked as deprecated as - in the majority of cases - it doesn't make sense to use it, if PIT is called using the Gradle - * plugin. Use #verosity instead.

+ * plugin. Use #verbosity instead.

* * @see #verbosity */ From 98f132e7028ac438ddf1ae98182bd2b75cba04a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Fri, 13 Jan 2023 21:33:38 +0100 Subject: [PATCH 41/60] Enforce older chandler dependencies compatible with Ruby 2.4 Which is required by no longer updated Chandler... --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index b0737093..f7ea34e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,11 @@ install: - ruby --version - rvm install 2.4.1 - ruby --version + # last Ruby 2.4 compatible version + - gem install --no-document faraday -v 1.10.1 + - gem install --no-document faraday-net_http -v 2.1.0 + - gem install --no-document public_suffix -v 4.0.7 + - gem install --no-document octokit -v 4.25.1 - gem install --no-document chandler -v 0.7.0 script: From c97fe8a7575674681badf5489712973effecd6a0 Mon Sep 17 00:00:00 2001 From: Francisco Daines Date: Fri, 10 Feb 2023 18:32:55 -0300 Subject: [PATCH 42/60] docs: Include instructions to load 'java' or 'java-library' plugins as needed (#331) Co-authored-by: Francisco Daines --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f806c0a6..c691c8e6 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Add gradle-pitest-plugin to the `plugins` configuration in your `build.gradle` f ```groovy plugins { + id 'java' //or 'java-library' - depending on your needs id 'info.solidsoft.pitest' version '1.9.11' } ``` @@ -55,6 +56,7 @@ buildscript { Apply the plugin: ```groovy +apply plugin: 'java' //or 'java-library' - depending on your needs apply plugin: 'info.solidsoft.pitest' ``` From f7407dca765be519c7c58e54370e576b44beb086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Wed, 5 Jul 2023 23:30:35 +0200 Subject: [PATCH 43/60] [#343] Remove deprecated Project.getConvention() usage Deprecated in Gradle 8.2 (to be removed in 9). For Gradle <7.1 dynamic hack is used. Closes #343. --- CHANGELOG.md | 6 ++++++ .../PitestPluginGradleVersionFunctionalSpec.groovy | 11 ++++++----- .../solidsoft/gradle/pitest/PitestPlugin.groovy | 14 +++++++++++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb6097b7..33fe7905 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # gradle-pitest-plugin changelog +## 1.14.0 - Unreleased + + - Remove deprecated Project.getConvention() usage (in Gradle 8.2+) - [#343](https://github.com/szpak/gradle-pitest-plugin/issues/343) + - Basic regression testing with Gradle up to 8.2 + + ## 1.9.11 - 2022-11-27 - Support for thresholds in aggregated metrics (requires PIT 1.9.9+) - [#319](https://github.com/szpak/gradle-pitest-plugin/issues/319) - PR by [pfoerd](https://github.com/Pfoerd) diff --git a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy index 35dcc89e..c573f084 100644 --- a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy +++ b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy @@ -31,9 +31,9 @@ import static info.solidsoft.gradle.pitest.PitestTaskConfigurationSpec.PIT_PARAM @CompileDynamic class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSpec { - private static final GradleVersion LATEST_KNOWN_GRADLE_VERSION = GradleVersion.version("7.6") + private static final GradleVersion LATEST_KNOWN_GRADLE_VERSION = GradleVersion.version("8.2") - //Baased on https://docs.gradle.org/current/userguide/compatibility.html + //Based on https://docs.gradle.org/current/userguide/compatibility.html private static final Map MINIMAL_GRADLE_VERSION_FOR_JAVA_VERSION = [ (JavaVersion.VERSION_15): GradleVersion.version("6.7"), (JavaVersion.VERSION_16): GradleVersion.version("7.0.2"), @@ -102,8 +102,9 @@ class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSp private static final String REGRESSION_TESTS_ENV_NAME = "PITEST_REGRESSION_TESTS" private static final List GRADLE6_VERSIONS = ["6.9.2", "6.8.3", "6.7", "6.6", "6.5", PitestPlugin.MINIMAL_SUPPORTED_GRADLE_VERSION.version] - private static final List GRADLE7_VERSIONS = [LATEST_KNOWN_GRADLE_VERSION.version, "7.5.1", "7.4.1", "7.3.3", "7.2", "7.1.1", "7.0.2"] - private static final List GRADLE_LATEST_VERSIONS = [GRADLE6_VERSIONS.first(), GRADLE7_VERSIONS.first(), + private static final List GRADLE7_VERSIONS = ["7.6.2", "7.5.1", "7.4.1", "7.3.3", "7.2", "7.1.1", "7.0.2"] + private static final List GRADLE8_VERSIONS = [LATEST_KNOWN_GRADLE_VERSION.version, "8.1.1", "8.0.2"] + private static final List GRADLE_LATEST_VERSIONS = [GRADLE6_VERSIONS.first(), GRADLE7_VERSIONS.first(), GRADLE8_VERSIONS.first(), PitestPlugin.MINIMAL_SUPPORTED_GRADLE_VERSION.version] @SuppressWarnings('GroovyFallthrough') @@ -117,7 +118,7 @@ class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSp case "quick": return GRADLE_LATEST_VERSIONS case "full": - return GRADLE6_VERSIONS + GRADLE7_VERSIONS + return GRADLE6_VERSIONS + GRADLE7_VERSIONS + GRADLE8_VERSIONS default: log.warn("Unsupported $REGRESSION_TESTS_ENV_NAME value '`$regressionTestsLevel`' (expected 'latestOnly', 'quick' or 'full'). " + "Assuming 'latestOnly'.") diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index fa9a49f5..646387f2 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -28,6 +28,7 @@ import org.gradle.api.logging.Logger import org.gradle.api.logging.Logging import org.gradle.api.plugins.JavaPlugin import org.gradle.api.plugins.JavaPluginConvention +import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.provider.Provider import org.gradle.api.reporting.ReportingExtension import org.gradle.api.tasks.Internal @@ -107,7 +108,7 @@ class PitestPlugin implements Plugin { extension = project.extensions.create("pitest", PitestPluginExtension, project) setupReportDirInExtensionWithProblematicTypeForGradle5() extension.pitestVersion.set(DEFAULT_PITEST_VERSION) - SourceSetContainer javaSourceSets = project.convention.getPlugin(JavaPluginConvention).sourceSets + SourceSetContainer javaSourceSets = getSourceSetContainer() extension.testSourceSets.set([javaSourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME)]) extension.mainSourceSets.set([javaSourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)]) extension.fileExtensionsToFilter.set(DEFAULT_FILE_EXTENSIONS_TO_FILTER_FROM_CLASSPATH) @@ -115,6 +116,17 @@ class PitestPlugin implements Plugin { extension.verbosity.set("NO_SPINNER") } + @CompileDynamic //Remove once only Gradle 7.1+ are supported + private SourceSetContainer getSourceSetContainer() { + GradleVersion minimalVersionWithSourceSetsInJavaPluginExtension = GradleVersion.version("7.1") + + if (GradleVersion.current() < minimalVersionWithSourceSetsInJavaPluginExtension) { + return project.convention.getPlugin(JavaPluginConvention).sourceSets + } else { + return project.extensions.getByType(JavaPluginExtension).sourceSets + } + } + private void failWithMeaningfulErrorMessageOnUnsupportedConfigurationInRootProjectBuildScript() { if (project.rootProject.buildscript.configurations.findByName(PITEST_CONFIGURATION_NAME) != null) { throw new GradleException("The '${PITEST_CONFIGURATION_NAME}' buildscript configuration found in the root project. " + From 00d7f3f8d6cd2c3aa3e74d0e83df8175516bce7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Thu, 6 Jul 2023 21:56:36 +0200 Subject: [PATCH 44/60] [#343] Simplify getting SourceSetContainer It is an extension itself and is compatible also with Gradle 6.4. --- .../solidsoft/gradle/pitest/PitestPlugin.groovy | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index 646387f2..7a3eee5c 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -27,8 +27,6 @@ import org.gradle.api.file.FileCollection import org.gradle.api.logging.Logger import org.gradle.api.logging.Logging import org.gradle.api.plugins.JavaPlugin -import org.gradle.api.plugins.JavaPluginConvention -import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.provider.Provider import org.gradle.api.reporting.ReportingExtension import org.gradle.api.tasks.Internal @@ -108,7 +106,7 @@ class PitestPlugin implements Plugin { extension = project.extensions.create("pitest", PitestPluginExtension, project) setupReportDirInExtensionWithProblematicTypeForGradle5() extension.pitestVersion.set(DEFAULT_PITEST_VERSION) - SourceSetContainer javaSourceSets = getSourceSetContainer() + SourceSetContainer javaSourceSets = project.extensions.getByType(SourceSetContainer) extension.testSourceSets.set([javaSourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME)]) extension.mainSourceSets.set([javaSourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)]) extension.fileExtensionsToFilter.set(DEFAULT_FILE_EXTENSIONS_TO_FILTER_FROM_CLASSPATH) @@ -116,17 +114,6 @@ class PitestPlugin implements Plugin { extension.verbosity.set("NO_SPINNER") } - @CompileDynamic //Remove once only Gradle 7.1+ are supported - private SourceSetContainer getSourceSetContainer() { - GradleVersion minimalVersionWithSourceSetsInJavaPluginExtension = GradleVersion.version("7.1") - - if (GradleVersion.current() < minimalVersionWithSourceSetsInJavaPluginExtension) { - return project.convention.getPlugin(JavaPluginConvention).sourceSets - } else { - return project.extensions.getByType(JavaPluginExtension).sourceSets - } - } - private void failWithMeaningfulErrorMessageOnUnsupportedConfigurationInRootProjectBuildScript() { if (project.rootProject.buildscript.configurations.findByName(PITEST_CONFIGURATION_NAME) != null) { throw new GradleException("The '${PITEST_CONFIGURATION_NAME}' buildscript configuration found in the root project. " + From 35012e5d6d58a16fd419477769f9a60de1e0cb98 Mon Sep 17 00:00:00 2001 From: davidburstrom Date: Wed, 12 Jul 2023 18:08:24 +0200 Subject: [PATCH 45/60] [#333] Fix Gradle configuration cache issues for 8.1 and up (#345) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [#333] Fix Gradle configuration cache issues for 8.1 and up The fix has a test but it's not hooked into the build because of cascading version incompatibility issues, which the pitest-gradle-plugin project needs to deal with. * [#333] Fix failing functional test with Gradle 8.1 By explicitly excluding not compatible Spock from its classpath. --------- Co-authored-by: Marcin Zajączkowski <148013+szpak@users.noreply.github.com> --- .../functional/Junit5FunctionalSpec.groovy | 17 +++++++++++++++++ ...testPluginGradleVersionFunctionalSpec.groovy | 5 ++++- .../solidsoft/gradle/pitest/PitestTask.groovy | 10 +++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy index 7f1985d8..637ed1a5 100644 --- a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy +++ b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy @@ -1,7 +1,9 @@ package info.solidsoft.gradle.pitest.functional +import com.google.common.base.Predicates import groovy.transform.CompileDynamic import nebula.test.functional.ExecutionResult +import nebula.test.functional.GradleRunner import spock.lang.Issue @CompileDynamic @@ -85,4 +87,19 @@ class Junit5FunctionalSpec extends AbstractPitestFunctionalSpec { result2.standardOutput.contains('Reusing configuration cache.') } + @Issue("https://github.com/szpak/gradle-pitest-plugin/issues/333") + void "should not reference project data at execution time (causing InvalidUserCodeException in Gradle 8.1+)"() { + given: + gradleVersion = "8.1" + classpathFilter = Predicates.and(GradleRunner.CLASSPATH_DEFAULT, PitestPluginGradleVersionFunctionalSpec.FILTER_SPOCK_JAR) + and: + copyResources("testProjects/junit5simple", "") + when: + ExecutionResult result = runTasks('pitest', '--configuration-cache', '--rerun-tasks') + then: + !result.standardError.contains('invocation of \'Task.project\' at execution time is unsupported.') + !result.failure + result.wasExecuted('pitest') + } + } diff --git a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy index c573f084..99c74f78 100644 --- a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy +++ b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy @@ -3,6 +3,7 @@ package info.solidsoft.gradle.pitest.functional import com.google.common.base.Predicate import com.google.common.base.Predicates import groovy.transform.CompileDynamic +import groovy.transform.PackageScope import groovy.util.logging.Slf4j import info.solidsoft.gradle.pitest.PitestPlugin import nebula.test.functional.ExecutionResult @@ -94,7 +95,9 @@ class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSp //To prevent failure when Spock for Groovy 2.5 is run with Groovy 3.0 delivered with Gradle 7+ //Spock is not needed in this artificial project - just the test classpath leaks to Gradle instance started by Nebula private static final Pattern SPOCK_JAR_PATTERN = Pattern.compile(".*spock-core-2\\..*.jar") - private static final Predicate FILTER_SPOCK_JAR = { URL url -> + @SuppressWarnings('JUnitPublicProperty') + @PackageScope + static final Predicate FILTER_SPOCK_JAR = { URL url -> return !url.toExternalForm().matches(SPOCK_JAR_PATTERN) } as Predicate diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy index 311b4ad2..9108fc73 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestTask.groovy @@ -249,10 +249,14 @@ class PitestTask extends JavaExec { @Optional List overriddenTargetTests //should be Set or SetProperty but it's not supported in Gradle as of 5.6.1 + @Internal + File rootDir + PitestTask() { getMainClass().set("org.pitest.mutationtest.commandline.MutationCoverageReport") ObjectFactory of = project.objects + rootDir = project.rootDir testPlugin = of.property(String) reportDir = of.directoryProperty() @@ -305,19 +309,19 @@ class PitestTask extends JavaExec { @Input String getAdditionalClasspathFilePath() { - return additionalClasspathFile.asFile.get().relativePath(project.rootProject.rootDir) + return additionalClasspathFile.asFile.get().relativePath(rootDir) } @Input @Optional String getHistoryInputLocationPath() { //?. operator doesn't work with Gradle Providers - return historyInputLocation.isPresent() ? historyInputLocation.asFile.get().relativePath(project.rootProject.rootDir) : null + return historyInputLocation.isPresent() ? historyInputLocation.asFile.get().relativePath(rootDir) : null } @Input String getDefaultFileForHistoryDataPath() { - return defaultFileForHistoryData.asFile.get().relativePath(project.rootProject.rootDir) + return defaultFileForHistoryData.asFile.get().relativePath(rootDir) } @Input From cbc320128da60dc84bab2438e258d99da097a88b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Tue, 5 Sep 2023 23:24:39 +0200 Subject: [PATCH 46/60] [#344] Improved logging for Aggregating pitest reports Just a useful leftover after debugging the issue which still is not solved. --- .../info/solidsoft/gradle/pitest/AggregateReportTask.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy index 2c1811f7..0e05d9e6 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/AggregateReportTask.groovy @@ -104,7 +104,7 @@ abstract class AggregateReportTask extends DefaultTask { @TaskAction void aggregate() { - logger.info("Aggregating pitest reports") + logger.info("Aggregating pitest reports (mutationFiles: {}, lineCoverageFiles: {})", mutationFiles.elements.getOrNull(), lineCoverageFiles.elements.getOrNull()) WorkQueue workQueue = getWorkerExecutor().classLoaderIsolation { workerSpec -> workerSpec.getClasspath().from(getPitestReportClasspath()) From 1b2906247afd77b46f370ee5cca58545a58b73fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Wed, 20 Sep 2023 23:39:20 +0200 Subject: [PATCH 47/60] [#337] Automatically add junit-platform-launcher to testRuntimeOnly ... for JUnit Platform projects to avoid "UNKNOWN_ERROR" or: "NoClassDefFoundError: org.junit.platform.launcher.core.LauncherFactory" with PIT 1.14.0+ (with pitest-junit-plugin 1.2.0+). That dependency is no longer shaded. More details: https://github.com/szpak/gradle-pitest-plugin/issues/337 --- CHANGELOG.md | 11 +++- .../functional/Junit5FunctionalSpec.groovy | 6 ++- .../testProjects/junit5kotlin/build.gradle | 6 +-- .../build-pit-plugin-1.0.0-junit-5.8.gradle | 33 ++++++++++++ .../testProjects/junit5simple/build.gradle | 11 ++-- .../gradle/pitest/PitestPlugin.groovy | 50 +++++++++++++++++++ .../pitest/PitestPluginExtension.groovy | 18 +++++++ 7 files changed, 122 insertions(+), 13 deletions(-) create mode 100644 src/funcTest/resources/testProjects/junit5simple/build-pit-plugin-1.0.0-junit-5.8.gradle diff --git a/CHANGELOG.md b/CHANGELOG.md index 33fe7905..15c8aa9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,18 @@ ## 1.14.0 - Unreleased - - Remove deprecated Project.getConvention() usage (in Gradle 8.2+) - [#343](https://github.com/szpak/gradle-pitest-plugin/issues/343) + - Automatically add `junit-platform-launcher` dependency to `testRuntimeOnly` for JUnit Platform projects - [#337](https://github.com/szpak/gradle-pitest-plugin/issues/337) - help from [Björn Kautler](https://github.com/Vampire) + - Remove deprecated `Project.getConvention()` usage (in Gradle 8.2+) - [#343](https://github.com/szpak/gradle-pitest-plugin/issues/343) - Basic regression testing with Gradle up to 8.2 +**Compatibility notes** +Starting with PIT 1.14.0 (with pitest-junit-plugin 1.2.0+) `junit-platform-launcher` is no longer shaded and has to be explicitly added to avoid: +"Minion exited abnormally due to UNKNOWN_ERROR" or "NoClassDefFoundError: org.junit.platform.launcher.core.LauncherFactory". + +As an experimental (incubating) feature, `junit-platform-launcher` is automatically added to the `testRuntimeOnly` configuration for the JUnit Platform projects. + +**PLEASE NOTE**. This feature is experimental and might not work as expected in some corner cases. In that situation, just disable it with `addJUnitPlatformLauncher = false` and add the required dependency 'junit-platform-launcher' in a proper version to 'testRuntimeOnly' manually. More information: https://github.com/szpak/gradle-pitest-plugin/issues/337 + ## 1.9.11 - 2022-11-27 diff --git a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy index 637ed1a5..e5cae986 100644 --- a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy +++ b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/Junit5FunctionalSpec.groovy @@ -33,7 +33,8 @@ class Junit5FunctionalSpec extends AbstractPitestFunctionalSpec { result.standardOutput.contains('Generated 2 mutations Killed 2 (100%)') } - @Issue(["https://github.com/szpak/gradle-pitest-plugin/issues/177", "https://github.com/szpak/gradle-pitest-plugin/issues/300"]) + @Issue(["https://github.com/szpak/gradle-pitest-plugin/issues/177", "https://github.com/szpak/gradle-pitest-plugin/issues/300", + "https://github.com/szpak/gradle-pitest-plugin/issues/337"]) void "should work with junit5 without explicitly adding dependency (#description)"() { given: copyResources("testProjects/junit5simple", "") @@ -51,7 +52,8 @@ class Junit5FunctionalSpec extends AbstractPitestFunctionalSpec { result.standardOutput.contains("junit-platform-commons-${expectedJUnitPlatformVersion}.jar") where: buildFileName || expectedJunitPluginVersion | expectedJUnitJupiterVersion | expectedJUnitPlatformVersion - 'build.gradle' || "1.0.0" | "5.8.0" | "1.8.0" + 'build.gradle' || "1.2.0" | "5.10.0" | "1.10.0" + 'build-pit-plugin-1.0.0-junit-5.8.gradle' || "1.0.0" | "5.8.0" | "1.8.0" 'build-pit-1.8-junit-platform-5.7.gradle' || "0.14" | "5.7.0" | "1.7.0" description = "plugin $expectedJunitPluginVersion, junit $expectedJUnitJupiterVersion, platform $expectedJUnitPlatformVersion" diff --git a/src/funcTest/resources/testProjects/junit5kotlin/build.gradle b/src/funcTest/resources/testProjects/junit5kotlin/build.gradle index f01834d5..377e9aff 100644 --- a/src/funcTest/resources/testProjects/junit5kotlin/build.gradle +++ b/src/funcTest/resources/testProjects/junit5kotlin/build.gradle @@ -1,7 +1,7 @@ buildscript { ext.kotlin_version = '1.3.61' - ext.junit5Version = '5.7.0' - ext.junitPlatformVersion = '1.7.0' + ext.junit5Version = '5.10.0' + ext.junitPlatformVersion = '1.10.0' repositories { mavenCentral() @@ -31,7 +31,7 @@ dependencies { testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version" testImplementation "org.junit.platform:junit-platform-runner:$junitPlatformVersion" - pitest 'org.pitest:pitest-junit5-plugin:1.0.0' + pitest 'org.pitest:pitest-junit5-plugin:1.2.0' } compileKotlin { diff --git a/src/funcTest/resources/testProjects/junit5simple/build-pit-plugin-1.0.0-junit-5.8.gradle b/src/funcTest/resources/testProjects/junit5simple/build-pit-plugin-1.0.0-junit-5.8.gradle new file mode 100644 index 00000000..58a82f0b --- /dev/null +++ b/src/funcTest/resources/testProjects/junit5simple/build-pit-plugin-1.0.0-junit-5.8.gradle @@ -0,0 +1,33 @@ +apply plugin: 'java' +apply plugin: 'info.solidsoft.pitest' + +/* +//Local/current version of the plugin should be put on a classpath earlier to override that plugin version +buildscript { + repositories { + mavenCentral() + mavenLocal() + } + dependencies { + classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:X.Y.Z-SNAPSHOT' + } +} +*/ + +repositories { + mavenCentral() +} + +group = "pitest.test" + +dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.0' +} + +test { + useJUnitPlatform() +} + +pitest { + junit5PluginVersion = "1.0.0" +} diff --git a/src/funcTest/resources/testProjects/junit5simple/build.gradle b/src/funcTest/resources/testProjects/junit5simple/build.gradle index afdf0cb5..c9747f0e 100644 --- a/src/funcTest/resources/testProjects/junit5simple/build.gradle +++ b/src/funcTest/resources/testProjects/junit5simple/build.gradle @@ -18,15 +18,10 @@ repositories { mavenCentral() } -dependencies { -// //Not needed, 'junit5PluginVersion' should implicitly add it in requested version -// pitest 'org.pitest:pitest-junit5-plugin:1.0.0' -} - group = "pitest.test" dependencies { - testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.0' + testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.0' } test { @@ -34,5 +29,7 @@ test { } pitest { - junit5PluginVersion = "1.0.0" + pitestVersion = "1.14.4" + junit5PluginVersion = "1.2.0" //with no longer shaded junit-platform-launcher + verbose = true //for "ClassNotFoundException: org.junit.platform.launcher.core.LauncherFactory" which should not happen } diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index 7a3eee5c..c264b6db 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -23,6 +23,9 @@ import org.gradle.api.GradleException import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.artifacts.Configuration +import org.gradle.api.artifacts.ModuleVersionIdentifier +import org.gradle.api.artifacts.result.ResolutionResult +import org.gradle.api.artifacts.result.ResolvedComponentResult import org.gradle.api.file.FileCollection import org.gradle.api.logging.Logger import org.gradle.api.logging.Logging @@ -112,6 +115,7 @@ class PitestPlugin implements Plugin { extension.fileExtensionsToFilter.set(DEFAULT_FILE_EXTENSIONS_TO_FILTER_FROM_CLASSPATH) extension.useClasspathFile.set(false) extension.verbosity.set("NO_SPINNER") + extension.addJUnitPlatformLauncher.set(true) } private void failWithMeaningfulErrorMessageOnUnsupportedConfigurationInRootProjectBuildScript() { @@ -239,6 +243,52 @@ class PitestPlugin implements Plugin { dependencies.add(project.dependencies.create(junit5PluginDependencyAsString)) } } + + addJUnitPlatformLauncherDependencyIfNeeded() + } + + private void addJUnitPlatformLauncherDependencyIfNeeded() { + Configuration testImplementation = project.configurations.findByName("testImplementation") + testImplementation.withDependencies { directDependencies -> + if (!extension.addJUnitPlatformLauncher.isPresent() || !extension.addJUnitPlatformLauncher.get()) { + log.info("'addJUnitPlatformLauncher' feature explicitly disabled in configuration. " + + "Add junit-platform-launcher manually or expect 'Minion exited abnormally due to UNKNOWN_ERROR' or 'NoClassDefFoundError'") + return + } + + //Note: For simplicity, adding also for older pitest-junit5-plugin versions (<1.2.0), which is not needed + + final String orgJUnitPlatformGroup = "org.junit.platform" + + log.debug("Direct ${testImplementation.name} dependencies (${directDependencies.size()}): ${directDependencies}") + + //copy() seems to copy also something that refers to original configuration and generates StackOverflow on getting components + Configuration tmpTestImplementation = project.configurations.maybeCreate("tmpTestImplementation") + directDependencies.each { directDependency -> + tmpTestImplementation.dependencies.add(directDependency) + } + + ResolutionResult resolutionResult = tmpTestImplementation.incoming.resolutionResult + Set allResolvedComponents = resolutionResult.allComponents + log.debug("All resolved components ${testImplementation.name} (${allResolvedComponents.size()}): ${allResolvedComponents}") + + ResolvedComponentResult foundJunitPlatformComponent = allResolvedComponents.find { ResolvedComponentResult componentResult -> + ModuleVersionIdentifier moduleVersion = componentResult.moduleVersion + return moduleVersion.group == orgJUnitPlatformGroup && + (moduleVersion.name == "junit-platform-engine" || moduleVersion.name == "junit-platform-commons") + } + + if (!foundJunitPlatformComponent) { + log.info("No ${orgJUnitPlatformGroup} components founds in ${testImplementation.name}, junit-platform-launcher will not be added") + return + } + + String junitPlatformLauncherDependencyAsString = "${orgJUnitPlatformGroup}:junit-platform-launcher:${foundJunitPlatformComponent.moduleVersion.version}" + log.info("${orgJUnitPlatformGroup} component (${foundJunitPlatformComponent}) found in ${testImplementation.name}, " + + "adding junit-platform-launcher (${junitPlatformLauncherDependencyAsString}) to testRuntimeOnly") + project.configurations.findByName("testRuntimeOnly").dependencies.add( + project.dependencies.create(junitPlatformLauncherDependencyAsString)) + } } private void suppressPassingDeprecatedTestPluginForNewerPitVersions(PitestTask pitestTask) { diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy index 48075706..744e03e6 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPluginExtension.groovy @@ -250,6 +250,23 @@ class PitestPluginExtension { @Incubating final ListProperty fileExtensionsToFilter + /** + * Adds 'junit-platform-launcher' automatically to the 'testRuntimeOnly' configuration. + * + * Starting with PIT 1.14.0 (with pitest-junit-plugin 1.2.0+) that dependency is no longer shaded and has to be explicitly added to avoid: + * "Minion exited abnormally due to UNKNOWN_ERROR" or "NoClassDefFoundError: org.junit.platform.launcher.core.LauncherFactory". + * This feature is enabled by default if junit-platform is found on the testImplementation classes. + * + * PLEASE NOTE. This feature is experimental and might not work as expected in some corner cases. In that situation, just disable it and add + * required dependency 'junit-platform-launcher' in a proper version to 'testRuntimeOnly' manually. + * + * More information: https://github.com/szpak/gradle-pitest-plugin/issues/337 + * + * @since 1.14.0 + */ + @Incubating + final Property addJUnitPlatformLauncher + final ReportAggregatorProperties reportAggregatorProperties PitestPluginExtension(Project project) { @@ -303,6 +320,7 @@ class PitestPluginExtension { outputCharset = of.property(Charset) features = nullListPropertyOf(p, String) fileExtensionsToFilter = nullListPropertyOf(p, String) + addJUnitPlatformLauncher = of.property(Boolean) reportAggregatorProperties = new ReportAggregatorProperties(of) } From 7977204e64ccdc664c4ecc13ef3400a117d30558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Wed, 20 Sep 2023 23:41:33 +0200 Subject: [PATCH 48/60] PIT 1.14.4 by default --- CHANGELOG.md | 1 + build.gradle | 2 +- .../groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15c8aa9c..5ffce04b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Automatically add `junit-platform-launcher` dependency to `testRuntimeOnly` for JUnit Platform projects - [#337](https://github.com/szpak/gradle-pitest-plugin/issues/337) - help from [Björn Kautler](https://github.com/Vampire) - Remove deprecated `Project.getConvention()` usage (in Gradle 8.2+) - [#343](https://github.com/szpak/gradle-pitest-plugin/issues/343) + - PIT 1.14.4 by default - Basic regression testing with Gradle up to 8.2 **Compatibility notes** diff --git a/build.gradle b/build.gradle index dee5f9b3..e85d3b95 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ buildscript { sourceCompatibility = 1.8 -ext.pitestAggregatorVersion = "1.9.11" //Must be equal to default PIT version in PitestPlugin +ext.pitestAggregatorVersion = "1.14.4" //Must be equal to default PIT version in PitestPlugin repositories { mavenCentral() diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index c264b6db..f6dc2a5d 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -54,7 +54,7 @@ class PitestPlugin implements Plugin { public final static String PITEST_REPORT_DIRECTORY_NAME = 'pitest' public final static String PITEST_CONFIGURATION_NAME = 'pitest' - public final static String DEFAULT_PITEST_VERSION = '1.9.11' + public final static String DEFAULT_PITEST_VERSION = '1.14.4' @Internal //6.4 due to main -> mainClass change to avoid deprecation warning in Gradle 7.x - https://github.com/szpak/gradle-pitest-plugin/pull/289 public static final GradleVersion MINIMAL_SUPPORTED_GRADLE_VERSION = GradleVersion.version("6.4") //public as used also in regression tests From 6d628c5105c906fd58fc06e4830e2cdf4e7a8475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Thu, 28 Sep 2023 20:09:06 +0200 Subject: [PATCH 49/60] [#337] Replace some findByName() with lazy named() --- .../gradle/pitest/PitestPlugin.groovy | 67 ++++++++++--------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index f6dc2a5d..59033b76 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -19,6 +19,7 @@ import groovy.transform.CompileDynamic import groovy.transform.CompileStatic import groovy.transform.PackageScope import info.solidsoft.gradle.pitest.internal.GradleVersionEnforcer +import org.gradle.api.Action import org.gradle.api.GradleException import org.gradle.api.Plugin import org.gradle.api.Project @@ -248,46 +249,48 @@ class PitestPlugin implements Plugin { } private void addJUnitPlatformLauncherDependencyIfNeeded() { - Configuration testImplementation = project.configurations.findByName("testImplementation") - testImplementation.withDependencies { directDependencies -> - if (!extension.addJUnitPlatformLauncher.isPresent() || !extension.addJUnitPlatformLauncher.get()) { - log.info("'addJUnitPlatformLauncher' feature explicitly disabled in configuration. " + - "Add junit-platform-launcher manually or expect 'Minion exited abnormally due to UNKNOWN_ERROR' or 'NoClassDefFoundError'") - return - } + project.configurations.named("testImplementation").configure { testImplementation -> + testImplementation.withDependencies { directDependencies -> + if (!extension.addJUnitPlatformLauncher.isPresent() || !extension.addJUnitPlatformLauncher.get()) { + log.info("'addJUnitPlatformLauncher' feature explicitly disabled in configuration. " + + "Add junit-platform-launcher manually or expect 'Minion exited abnormally due to UNKNOWN_ERROR' or 'NoClassDefFoundError'") + return + } - //Note: For simplicity, adding also for older pitest-junit5-plugin versions (<1.2.0), which is not needed + //Note: For simplicity, adding also for older pitest-junit5-plugin versions (<1.2.0), which is not needed - final String orgJUnitPlatformGroup = "org.junit.platform" + final String orgJUnitPlatformGroup = "org.junit.platform" - log.debug("Direct ${testImplementation.name} dependencies (${directDependencies.size()}): ${directDependencies}") + log.debug("Direct ${testImplementation.name} dependencies (${directDependencies.size()}): ${directDependencies}") - //copy() seems to copy also something that refers to original configuration and generates StackOverflow on getting components - Configuration tmpTestImplementation = project.configurations.maybeCreate("tmpTestImplementation") - directDependencies.each { directDependency -> - tmpTestImplementation.dependencies.add(directDependency) - } + //copy() seems to copy also something that refers to original configuration and generates StackOverflow on getting components + Configuration tmpTestImplementation = project.configurations.maybeCreate("tmpTestImplementation") + directDependencies.each { directDependency -> + tmpTestImplementation.dependencies.add(directDependency) + } - ResolutionResult resolutionResult = tmpTestImplementation.incoming.resolutionResult - Set allResolvedComponents = resolutionResult.allComponents - log.debug("All resolved components ${testImplementation.name} (${allResolvedComponents.size()}): ${allResolvedComponents}") + ResolutionResult resolutionResult = tmpTestImplementation.incoming.resolutionResult + Set allResolvedComponents = resolutionResult.allComponents + log.debug("All resolved components ${testImplementation.name} (${allResolvedComponents.size()}): ${allResolvedComponents}") - ResolvedComponentResult foundJunitPlatformComponent = allResolvedComponents.find { ResolvedComponentResult componentResult -> - ModuleVersionIdentifier moduleVersion = componentResult.moduleVersion - return moduleVersion.group == orgJUnitPlatformGroup && - (moduleVersion.name == "junit-platform-engine" || moduleVersion.name == "junit-platform-commons") - } + ResolvedComponentResult foundJunitPlatformComponent = allResolvedComponents.find { ResolvedComponentResult componentResult -> + ModuleVersionIdentifier moduleVersion = componentResult.moduleVersion + return moduleVersion.group == orgJUnitPlatformGroup && + (moduleVersion.name == "junit-platform-engine" || moduleVersion.name == "junit-platform-commons") + } - if (!foundJunitPlatformComponent) { - log.info("No ${orgJUnitPlatformGroup} components founds in ${testImplementation.name}, junit-platform-launcher will not be added") - return - } + if (!foundJunitPlatformComponent) { + log.info("No ${orgJUnitPlatformGroup} components founds in ${testImplementation.name}, junit-platform-launcher will not be added") + return + } - String junitPlatformLauncherDependencyAsString = "${orgJUnitPlatformGroup}:junit-platform-launcher:${foundJunitPlatformComponent.moduleVersion.version}" - log.info("${orgJUnitPlatformGroup} component (${foundJunitPlatformComponent}) found in ${testImplementation.name}, " + - "adding junit-platform-launcher (${junitPlatformLauncherDependencyAsString}) to testRuntimeOnly") - project.configurations.findByName("testRuntimeOnly").dependencies.add( - project.dependencies.create(junitPlatformLauncherDependencyAsString)) + String junitPlatformLauncherDependencyAsString = "${orgJUnitPlatformGroup}:junit-platform-launcher:${foundJunitPlatformComponent.moduleVersion.version}" + log.info("${orgJUnitPlatformGroup} component (${foundJunitPlatformComponent}) found in ${testImplementation.name}, " + + "adding junit-platform-launcher (${junitPlatformLauncherDependencyAsString}) to testRuntimeOnly") + project.configurations.named("testRuntimeOnly").configure({ Configuration testRuntimeOnly -> + testRuntimeOnly.dependencies.add(project.dependencies.create(junitPlatformLauncherDependencyAsString)) + } as Action) + } } } From 3186ab920fd30cfd54ad48a64907ca413d0724e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Thu, 28 Sep 2023 20:29:06 +0200 Subject: [PATCH 50/60] PIT 1.15.0 by default --- CHANGELOG.md | 4 ++-- build.gradle | 2 +- .../groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ffce04b..7b7886bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,10 @@ # gradle-pitest-plugin changelog -## 1.14.0 - Unreleased +## 1.15.0 - Unreleased - Automatically add `junit-platform-launcher` dependency to `testRuntimeOnly` for JUnit Platform projects - [#337](https://github.com/szpak/gradle-pitest-plugin/issues/337) - help from [Björn Kautler](https://github.com/Vampire) - Remove deprecated `Project.getConvention()` usage (in Gradle 8.2+) - [#343](https://github.com/szpak/gradle-pitest-plugin/issues/343) - - PIT 1.14.4 by default + - PIT 1.15.0 by default - Basic regression testing with Gradle up to 8.2 **Compatibility notes** diff --git a/build.gradle b/build.gradle index e85d3b95..b253cb15 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ buildscript { sourceCompatibility = 1.8 -ext.pitestAggregatorVersion = "1.14.4" //Must be equal to default PIT version in PitestPlugin +ext.pitestAggregatorVersion = "1.15.0" //Must be equal to default PIT version in PitestPlugin repositories { mavenCentral() diff --git a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy index 59033b76..bafa28d8 100644 --- a/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/info/solidsoft/gradle/pitest/PitestPlugin.groovy @@ -55,7 +55,7 @@ class PitestPlugin implements Plugin { public final static String PITEST_REPORT_DIRECTORY_NAME = 'pitest' public final static String PITEST_CONFIGURATION_NAME = 'pitest' - public final static String DEFAULT_PITEST_VERSION = '1.14.4' + public final static String DEFAULT_PITEST_VERSION = '1.15.0' @Internal //6.4 due to main -> mainClass change to avoid deprecation warning in Gradle 7.x - https://github.com/szpak/gradle-pitest-plugin/pull/289 public static final GradleVersion MINIMAL_SUPPORTED_GRADLE_VERSION = GradleVersion.version("6.4") //public as used also in regression tests From 61bfba9bbc6d9d86ceb90e1e07bfc8e82113b8e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Thu, 28 Sep 2023 20:35:27 +0200 Subject: [PATCH 51/60] Bump maximum Gradle version in regression tests to 8.3 --- CHANGELOG.md | 2 +- .../functional/PitestPluginGradleVersionFunctionalSpec.groovy | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b7886bb..744c6567 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - Automatically add `junit-platform-launcher` dependency to `testRuntimeOnly` for JUnit Platform projects - [#337](https://github.com/szpak/gradle-pitest-plugin/issues/337) - help from [Björn Kautler](https://github.com/Vampire) - Remove deprecated `Project.getConvention()` usage (in Gradle 8.2+) - [#343](https://github.com/szpak/gradle-pitest-plugin/issues/343) - PIT 1.15.0 by default - - Basic regression testing with Gradle up to 8.2 + - Basic regression testing with Gradle up to 8.3 **Compatibility notes** Starting with PIT 1.14.0 (with pitest-junit-plugin 1.2.0+) `junit-platform-launcher` is no longer shaded and has to be explicitly added to avoid: diff --git a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy index 99c74f78..f7e954fc 100644 --- a/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy +++ b/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginGradleVersionFunctionalSpec.groovy @@ -32,7 +32,7 @@ import static info.solidsoft.gradle.pitest.PitestTaskConfigurationSpec.PIT_PARAM @CompileDynamic class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSpec { - private static final GradleVersion LATEST_KNOWN_GRADLE_VERSION = GradleVersion.version("8.2") + private static final GradleVersion LATEST_KNOWN_GRADLE_VERSION = GradleVersion.version("8.3") //Based on https://docs.gradle.org/current/userguide/compatibility.html private static final Map MINIMAL_GRADLE_VERSION_FOR_JAVA_VERSION = [ @@ -106,7 +106,7 @@ class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSp private static final List GRADLE6_VERSIONS = ["6.9.2", "6.8.3", "6.7", "6.6", "6.5", PitestPlugin.MINIMAL_SUPPORTED_GRADLE_VERSION.version] private static final List GRADLE7_VERSIONS = ["7.6.2", "7.5.1", "7.4.1", "7.3.3", "7.2", "7.1.1", "7.0.2"] - private static final List GRADLE8_VERSIONS = [LATEST_KNOWN_GRADLE_VERSION.version, "8.1.1", "8.0.2"] + private static final List GRADLE8_VERSIONS = [LATEST_KNOWN_GRADLE_VERSION.version, "8.2.1", "8.1.1", "8.0.2"] private static final List GRADLE_LATEST_VERSIONS = [GRADLE6_VERSIONS.first(), GRADLE7_VERSIONS.first(), GRADLE8_VERSIONS.first(), PitestPlugin.MINIMAL_SUPPORTED_GRADLE_VERSION.version] From 58cc0f14e8d1bbb848657d49227d47e46fd8981b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Thu, 28 Sep 2023 20:46:32 +0200 Subject: [PATCH 52/60] Trigger release [#DO_RELEASE][#1.15.0] From 74a43fa69069bd0271df989c941381e22cf9b11f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Thu, 28 Sep 2023 21:15:13 +0200 Subject: [PATCH 53/60] Release version: 1.15.0 --- CHANGELOG.md | 2 +- README.md | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 744c6567..16c45754 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # gradle-pitest-plugin changelog -## 1.15.0 - Unreleased +## 1.15.0 - 2023-09-28 - Automatically add `junit-platform-launcher` dependency to `testRuntimeOnly` for JUnit Platform projects - [#337](https://github.com/szpak/gradle-pitest-plugin/issues/337) - help from [Björn Kautler](https://github.com/Vampire) - Remove deprecated `Project.getConvention()` usage (in Gradle 8.2+) - [#343](https://github.com/szpak/gradle-pitest-plugin/issues/343) diff --git a/README.md b/README.md index c691c8e6..3e2e7939 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Add gradle-pitest-plugin to the `plugins` configuration in your `build.gradle` f ```groovy plugins { id 'java' //or 'java-library' - depending on your needs - id 'info.solidsoft.pitest' version '1.9.11' + id 'info.solidsoft.pitest' version '1.15.0' } ``` @@ -48,7 +48,7 @@ buildscript { //maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { - classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.9.11' + classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.15.0' } } ``` @@ -69,7 +69,7 @@ The Pitest plugin does not need to be additionally configured if you use JUnit 4 ```groovy pitest { targetClasses = ['our.base.package.*'] //by default "${project.group}.*" - pitestVersion = '1.9.11' //not needed when a default PIT version should be used + pitestVersion = '1.15.0' //not needed when a default PIT version should be used threads = 4 outputFormats = ['XML', 'HTML'] timestampedReports = false @@ -150,7 +150,7 @@ all subprojects which should be processed with PIT. A sample snippet from build. ```groovy //in root project configuration plugins { - id 'info.solidsoft.pitest' version '1.9.11' apply false + id 'info.solidsoft.pitest' version '1.15.0' apply false } subprojects { @@ -173,7 +173,7 @@ task `pitestReportAggregate`. Root project must be properly configured to use `p ```groovy //in root project configuration plugins { - id 'info.solidsoft.pitest' version '1.9.11' apply false + id 'info.solidsoft.pitest' version '1.15.0' apply false } apply plugin: 'info.solidsoft.pitest.aggregator' // to 'pitestReportAggregate' appear @@ -252,7 +252,7 @@ Starting with this release the configuration required to use PIT with JUnit 5 ha ```groovy plugins { id 'java' - id 'info.solidsoft.pitest' version '1.9.11' + id 'info.solidsoft.pitest' version '1.15.0' } pitest { @@ -275,7 +275,7 @@ To enable PIT plugins, it is enough to add it to the pitest configuration in the ```groovy plugins { id 'java' - id 'info.solidsoft.pitest' version '1.9.11' + id 'info.solidsoft.pitest' version '1.15.0' } repositories { From 512c4cc9f95c46021c9f523c77aaff808992f2e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Thu, 28 Sep 2023 21:37:21 +0200 Subject: [PATCH 54/60] Bump buty-buddy version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b253cb15..5e4e0cf9 100644 --- a/build.gradle +++ b/build.gradle @@ -46,7 +46,7 @@ dependencies { testImplementation('org.spockframework:spock-junit4:2.3-groovy-2.5') { exclude group: 'org.codehaus.groovy' } - testImplementation 'net.bytebuddy:byte-buddy:1.12.19' //for Spying in Spock + testImplementation 'net.bytebuddy:byte-buddy:1.14.8' //for Spying in Spock funcTestImplementation sourceSets.main.output //to make production plugin classes visible in functional tests (it's not in testCompile configuration) funcTestImplementation sourceSets.test.output From 8530f1fb0d72e9b513868a490af4d0be3cfdb86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= <148013+szpak@users.noreply.github.com> Date: Thu, 28 Sep 2023 23:40:09 +0200 Subject: [PATCH 55/60] Update Travis configuration --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f7ea34e0..29d5fc6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,10 +33,8 @@ env: global: - secure: HfMYoa5jyF43g33PZZYOqPDu53z5//MdKRBy3C7EVxK8akje833YFJUARPJtfi0VR6Moa+JhUGkkDLFxQc2f4kL+q0NO39ULfkFLgOcPYHETNw8u2N8SGvksv0qUSNDnOImHqUkUZ8I8PlHzP3u/pclU4d4gfs/m3aoOm1pYeEc= - secure: bszdL2Ib7xbHHNuCPKq0sj4mxH2GDPcyFKSKfyGGqpupcaZfsYQtuuxDtVFhkW1Uh+BcEJ8XhS/iXHJrgLwirz0/tgbDm2cz2nUxR5fkcmTm50Rep3QfoDeYMMq9mkuCw6B9Vz/M4eEamSBfgxpqPGA96yhtBG8KklFLWc/6++o= - - secure: VqF/aEXsmRj2d8azHFEAop5J8U57RP3B8w3p3LfDhdbXz/xOhXVBbm4CVZqeddKUAi7QFNjUi8ry+k8MbuFbzG0of0Pwg/fqWpRqpr+QdhUWiiVnlH42G2jqzgRxQRqyN7vjjPaEBA84PM0L8rlVUqx57s8ePCIuEAhvZ4urtFQ= - secure: Oco34JI8O6pDISUjogUuqGFYRmrI6m3wZkrzMbj3dwjQ3gna1q7S5FmZWVbQelkufJ5jP1V7Ny7QjeqGX4yDsaj+gt1QF/nbZvWRnOXu3gastspEfZrPEziOngfIH4//urUaFqikdPdqmvXqLvCvtW7TaWDvN3NDb1Rx1w8kiYg= - secure: cyJye89u5k+Ct13HC95LME72pdsXmtmWJIR3x4MxQfvFG/Q1Uz3FtnSj7oJH5xJ9oH3bzHd0k5sB38u1g2LTIov/Em+dSVBIGgcs49nMSlbVye0Ilt7A1x0c/7LidxKT/DiWu4jgFcf8VyEdd9LVQXBaO12sLsk6nk6RjTUKnU8= - - secure: FZfezOymfoKWQf+DHb6OU2Vk1cY8Cz0ic3+ZtPKoWRrp8bijkSIA8jjfzwKNbJ1qyRthTY7tv/k83dbrOl3xDBeT6yzXslceraWLww/cp/+FGM6M3XG6dLqZlSaKH8bbPL94p7NiPCn+7mSuirur1H9Lf4lD6VeAOmxtstowPic= matrix: include: - jdk: openjdk11 From 3752a463b71648cec3c36a6d52a2f81d366d881c Mon Sep 17 00:00:00 2001 From: Ivan Vakhrushev Date: Tue, 10 Oct 2023 00:37:33 +0400 Subject: [PATCH 56/60] Added examples of using plugin with Kotlin DSL (#355) * Added Kotlin DSL examples to README.md * Added example of pitest aggregated report * Updated pitest version and configuration for aggregated report * Code review fixes * Added both configuration versions --------- Co-authored-by: i.n.vakhrushev --- README.md | 276 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 269 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3e2e7939..c7c053fc 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,17 @@ plugins { } ``` +
+with Kotlin DSL + +```kotlin +plugins { + id("java") //or "java-library" - depending on your needs + id("info.solidsoft.pitest") version "1.15.0" +} +``` +
+ Call Gradle with pitest task: gradle pitest @@ -34,7 +45,17 @@ Optionally make it depend on build: build.dependsOn 'pitest' ``` -Note that when making `pitest` depend on another task, it must be referred to by name. Otherwise Gradle will resolve `pitest` to the configuration and not the task. +
+with Kotlin DSL + +```kotlin +tasks.build { + dependsOn("pitest") +} +``` +
+ +Note that when making `pitest` depend on another task, it must be referred to by name. Otherwise, Gradle will resolve `pitest` to the configuration and not the task. ### Generic approach @@ -53,6 +74,25 @@ buildscript { } ``` +
+with Kotlin DSL + +```kotlin +buildscript { + repositories { + mavenCentral() + //Needed only for SNAPSHOT versions + //maven { + // url = uri("https://oss.sonatype.org/content/repositories/snapshots/") + //} + } + dependencies { + classpath("info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.15.0") + } +} +``` +
+ Apply the plugin: ```groovy @@ -60,6 +100,15 @@ apply plugin: 'java' //or 'java-library' - depending on your needs apply plugin: 'info.solidsoft.pitest' ``` +
+with Kotlin DSL + +```kotlin +apply(plugin = "java") //or "java-library" - depending on your needs +apply(plugin = "info.solidsoft.pitest") +``` +
+ ## Plugin configuration @@ -76,6 +125,33 @@ pitest { } ``` +
+with Kotlin DSL + +Idiomatic and more portable configuration: +```kotlin +pitest { + targetClasses.set(setOf("our.base.package.*")) //by default "${project.group}.*" + pitestVersion.set("1.15.0") //not needed when a default PIT version should be used + threads.set(4) + outputFormats.set(setOf("XML", "HTML")) + timestampedReports.set(false) +} +``` + +Starting from **Gradle 8.1** [simple property assignment](https://docs.gradle.org/8.4/release-notes.html#simple-property-assignment-in-kotlin-dsl-is-now-stable) +can be used for configuring plugin (instead of the `set()` method): +```kotlin +pitest { + targetClasses = setOf("our.base.package.*") //by default "${project.group}.*" + pitestVersion = "1.15.0" //not needed when a default PIT version should be used + threads = 4 + outputFormats = setOf("XML", "HTML") + timestampedReports = false +} +``` +
+ The configuration in Gradle is the real Groovy code which makes all assignments very intuitive. All values expected by PIT should be passed as a corresponding types. There is only one important difference. For the parameters where PIT expects a coma separated list of strings in a Gradle configuration a list of strings should be used (see `outputFormats` in the @@ -113,6 +189,21 @@ pitest { } ``` +
+with Kotlin DSL + +```kotlin +pitest { + ... + testSourceSets.set(listOf(sourceSets.test.get(), sourceSets.getByName("integrationTest"))) + mainSourceSets.set(listOf(sourceSets.main.get(), sourceSets.getByName("additionalMain"))) + jvmArgs.set(listOf("-Xmx1024m")) + useClasspathFile.set(true) //useful with bigger projects on Windows + fileExtensionsToFilter.addAll("xml", "orbit") +} +``` +
+ ### Test system properties PIT executes tests in a JVM independent of the JVM used by Gradle to execute tests. If your tests require some system properties, you have to pass them to PIT as the plugin won't do it for you: @@ -127,9 +218,25 @@ pitest { } ``` -### Eliminate warning in Idea +
+with Kotlin DSL -As reported in [#170](https://github.com/szpak/gradle-pitest-plugin/pull/170) IntelliJ IDEA displays warnings about setting final fields (of [lazy configuration](https://docs.gradle.org/current/userguide/lazy_configuration.html)) in `build.gradle`. It is not a real problem as Gradle internally intercepts those calls and use a setter instead . Nevertheless, people which prefer to have no (less) warnings at the cost of less readable code can use setters instead, e.g: +```kotlin +tasks.test { + systemProperty("spring.test.constructor.autowire.mode", "all") +} + +pitest { + jvmArgs.set(listOf("-Dspring.test.constructor.autowire.mode=all")) +} +``` +
+ +### Eliminate warning in IDEA (Groovy-only) + +As reported in [#170](https://github.com/szpak/gradle-pitest-plugin/pull/170) IntelliJ IDEA displays warnings about setting final fields (of [lazy configuration](https://docs.gradle.org/current/userguide/lazy_configuration.html)) in `build.gradle`. +It is not a real problem as Gradle internally intercepts those calls and use a setter instead. +Nevertheless, people which prefer to have no (less) warnings at the cost of less readable code can use setters instead, e.g: ```groovy testSourceSets.set([sourceSets.test, sourceSets.integrationTest]) @@ -139,8 +246,6 @@ As reported in [#170](https://github.com/szpak/gradle-pitest-plugin/pull/170) In fileExtensionsToFilter.addAll('xml', 'orbit') ``` -Similar syntax can be used also for Kotlin configuration (`build.gradle.kts`). - ## Multi-module projects support gradle-pitest-plugin can be used in [multi-module projects](src/funcTest/resources/testProjects/multiproject/build.gradle). @@ -166,6 +271,31 @@ subprojects { } } ``` + +
+with Kotlin DSL + +```kotlin +//in root project configuration +plugins { + id("info.solidsoft.pitest") version "1.15.0" +} + +subprojects { + apply(plugin = "java") + apply(plugin = "info.solidsoft.pitest") + + pitest { + threads.set(4) + + if (project.name in setOf("module-without-any-test")) { + failWhenNoMutations.set(false) + } + } +} +``` +
+ It is possible to aggregate pitest report for multi-module project using plugin `info.solidsoft.pitest.aggregator` and task `pitestReportAggregate`. Root project must be properly configured to use `pitestReportAggregate` : @@ -197,6 +327,35 @@ subprojects { } ``` +
+with Kotlin DSL + +```kotlin +//in root project configuration +plugins { + id("info.solidsoft.pitest") version "1.15.0" +} +apply(plugin = "info.solidsoft.pitest.aggregator") + +subprojects { + apply(plugin = "java") + apply(plugin = "info.solidsoft.pitest") + + pitest { + outputFormats.set(setOf("XML")) + timestampedReports.set(false) + exportLineCoverage.set(true) + ... + reportAggregator { + testStrengthThreshold.set(50) + mutationThreshold.set(40) + maxSurviving.set(3) + } + } +} +``` +
+ After the `pitest pitestReportAggregate` tasks execution, the aggregated report will be placed in the `${PROJECT_DIR}/build/reports/pitest` directory. ## Integration tests in separate subproject @@ -209,7 +368,7 @@ to make it work it is required to define both `mainSourceSets` and `additionalMu configure(project(':itest')) { apply plugin: 'info.solidsoft.pitest' dependencies { - compile project(':shared') + implementation project(':shared') } configurations { mutableCodeBase { transitive false } } @@ -221,6 +380,26 @@ configure(project(':itest')) { } ``` +
+with Kotlin DSL + +```kotlin +configure(listOf(project(":itest"))) { + apply(plugin = "info.solidsoft.pitest") + dependencies { + implementation(project(":shared")) + } + + val mutableCodeBase by configurations.creating { isTransitive = false } + dependencies { mutableCodeBase(project(":shared")) } + pitest { + mainSourceSets.set(listOf(project.sourceSets.main.get(), project(":shared").sourceSets.main.get())) + additionalMutableCodePaths.set(listOf(mutableCodeBase.singleFile)) + } +} +``` +
+ The above is the way recommended by the [Gradle team](http://forums.gradle.org/gradle/topics/how-to-get-file-path-to-binary-jar-produced-by-subproject#reply_15315782), but in specific cases the simpler solution should also work: @@ -228,7 +407,7 @@ but in specific cases the simpler solution should also work: configure(project(':itest')) { apply plugin: 'info.solidsoft.pitest' dependencies { - compile project(':shared') + implementation project(':shared') } pitest { @@ -238,6 +417,24 @@ configure(project(':itest')) { } ``` +
+with Kotlin DSL + +```kotlin +configure(listOf(project(":itest"))) { + apply(plugin = "info.solidsoft.pitest") + dependencies { + implementation(project(":shared")) + } + + pitest { + mainSourceSets.set(listOf(project.sourceSets.main.get(), project(":shared").sourceSets.main.get())) + additionalMutableCodePaths.set(project(":shared").task("jar").outputs.files) + } +} +``` +
+ Minimal working multi-project build is available in [functional tests suite](https://github.com/szpak/gradle-pitest-plugin/tree/master/src/funcTest/resources/testProjects/multiproject). @@ -262,6 +459,22 @@ pitest { } ``` +
+with Kotlin DSL + +```kotlin +plugins { + id("java") + id("info.solidsoft.pitest") version "1.15.0" +} + +pitest { + // adds dependency to org.pitest:pitest-junit5-plugin and sets "testPlugin" to "junit5" + junit5PluginVersion.set("1.0.0") +} +``` +
+ **Please note**. PIT 1.9.0 requires pitest-junit5-plugin 1.0.0+. JUnit Jupiter 5.8 (JUnit Platform 1.8) requires pitest-junit5-plugin 0.15+, while 5.7 (1.7) requires 0.14. Set right plugin version for JUnit 5 version used in your project to avoid runtime errors (such as [`NoSuchMethodError: 'java.util.Optional org.junit.platform.commons.util.AnnotationUtils.findAnnotation(java.lang.Class, java.lang.Class, boolean)'](https://github.com/szpak/gradle-pitest-plugin/issues/300))). The minimal working example for JUnit 5 is available in the [functional tests suite](https://github.com/szpak/gradle-pitest-plugin/blob/master/src/funcTest/resources/testProjects/junit5simple/build.gradle). @@ -287,6 +500,25 @@ dependencies { } ``` +
+with Kotlin DSL + +```kotlin +plugins { + id("java") + id("info.solidsoft.pitest") version "1.15.0" +} + +repositories { + mavenCentral() +} + +dependencies { + pitest("org.example.pit.plugins:pitest-custom-plugin:0.42") +} +``` +
+ The minimal working example is available in the [functional tests suite](https://github.com/szpak/gradle-pitest-plugin/blob/master/src/funcTest/groovy/info/solidsoft/gradle/pitest/functional/PitestPluginFunctional1Spec.groovy#L69-91). Please note. In gradle-pitest-plugin <1.5.0 the `pitest` configuration had to be created in the `buildscript` scope for the root project. @@ -343,6 +575,16 @@ pitest { } ``` +
+with Kotlin DSL + +```kotlin +pitest { + pitestVersion.set("2.8.1-the.greatest.one") +} +``` +
+ In case of errors detected when the latest available version of the plugin is used with newer PIT version please raise an [issue](https://github.com/szpak/gradle-pitest-plugin/issues). ### How to disable placing PIT reports in time-based subfolders? @@ -355,6 +597,16 @@ pitest { } ``` +
+with Kotlin DSL + +```kotlin +pitest { + timestampedReports.set(false) +} +``` +
+ ### How can I debug a gradle-pitest-plugin execution or a PIT process execution itself in a Gradle build? Occasionally, it may be useful to debug a gradle-pitest-plugin execution or a PIT execution itself (e.g. [NPE in PIT](https://github.com/hcoles/pitest/issues/345)) to provide sensible error report. @@ -369,6 +621,16 @@ pitest { } ``` +
+with Kotlin DSL + +```kotlin +pitest { + mainProcessJvmArgs.set(listOf("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005")) +} +``` +
+ ### Can I use gradle-pitest-plugin with my Android application? Short answer is: not directly. Due to some [incompatibilities](https://github.com/szpak/gradle-pitest-plugin/issues/31) between "standard" Java applications and Android Java applications in Gradle the plugin does not support the later. Luckily, there is an Android [fork](https://github.com/koral--/gradle-pitest-plugin/) of the plugin maintained by [Karol Wrótniak](https://github.com/koral--) which provides a modified version supporting Android applications (but on the other hand it doesn't work with standard Java applications). From 357522f63077f3c03fd1b06560e859710e212ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20Wr=C3=B3tniak?= Date: Thu, 2 Nov 2023 20:52:08 +0100 Subject: [PATCH 57/60] Copy runtime classpath only if jetifier is disabled Works around #99 --- .../resources/testProjects/simpleKotlin/gradle.properties | 2 ++ .../groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 src/funcTest/resources/testProjects/simpleKotlin/gradle.properties diff --git a/src/funcTest/resources/testProjects/simpleKotlin/gradle.properties b/src/funcTest/resources/testProjects/simpleKotlin/gradle.properties new file mode 100644 index 00000000..646c51b9 --- /dev/null +++ b/src/funcTest/resources/testProjects/simpleKotlin/gradle.properties @@ -0,0 +1,2 @@ +android.useAndroidX=true +android.enableJetifier=true diff --git a/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy index 3666b2c3..48fd7b1c 100644 --- a/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy @@ -196,7 +196,7 @@ class PitestPlugin implements Plugin { } else if (ANDROID_GRADLE_PLUGIN_VERSION_NUMBER.major == 4) { from(project.configurations["compile"]) from(project.configurations["testCompile"]) - } else if (ANDROID_GRADLE_PLUGIN_VERSION_NUMBER.major > 4) { + } else if (ANDROID_GRADLE_PLUGIN_VERSION_NUMBER.major > 4 && project.findProperty("android.enableJetifier") != true) { from(project.configurations["${variant.name}UnitTestRuntimeClasspath"].copyRecursive { configuration -> configuration.properties.dependencyProject == null }) From a02fa1161c281d0f0c6e3f1aedc164c8a77da2db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20Wr=C3=B3tniak?= Date: Sun, 5 Nov 2023 01:37:39 +0100 Subject: [PATCH 58/60] Ignore dependencies without version when copying unit test runtime classpath Fixes #100 --- .../groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy index 48fd7b1c..bc8dc373 100644 --- a/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy @@ -198,7 +198,7 @@ class PitestPlugin implements Plugin { from(project.configurations["testCompile"]) } else if (ANDROID_GRADLE_PLUGIN_VERSION_NUMBER.major > 4 && project.findProperty("android.enableJetifier") != true) { from(project.configurations["${variant.name}UnitTestRuntimeClasspath"].copyRecursive { configuration -> - configuration.properties.dependencyProject == null + configuration.properties.dependencyProject == null && configuration.version != null }) } from(project.configurations["pitestRuntimeOnly"]) From 1eff476e0b297b2c98470cbbba071e1d9b932532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20Wr=C3=B3tniak?= Date: Mon, 6 Nov 2023 02:07:14 +0100 Subject: [PATCH 59/60] Add notice about jetifier and automatic pitest dependency copying to README --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 402bdb24..45cba2d1 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,22 @@ pitest { ``` In such case default mockable Android JAR won't be added and alternative one will be used under tests. +## Using jetifier +This plugin tries to discover all the unit test dependencies and add them to the pitest classpath automatically. +But, this feature doesn't work with [jetifier](https://developer.android.com/studio/command-line/jetifier) +(`android.enableJetifier=true` in `gradle.properties`). + +If you are using jetifier and encounter `NoClassDefFoundError`s in tests run under pitest, you may want to add +some dependencies manually to the `pitestTestCompile` configuration. For example: +```groovy +buildscript { + configurations.create("pitestTestCompile") + dependencies { + pitestTestCompile 'io.mockk:mockk-agent-jvm:1.11.0' + } +} +``` + # Troubleshooting ## Tests fail when run under pitest but pass without it Issue occurs when using [Android API](https://developer.android.com/reference/packages.html) From 22252acee5c0a8275bc9ff35bdd92c100beebaa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20Wr=C3=B3tniak?= Date: Mon, 6 Nov 2023 02:58:50 +0100 Subject: [PATCH 60/60] Add mockable Android JAR dependencies automatically. Fixes #91 --- .../MockableAndroidJarFunctionalSpec.groovy | 1 + .../test/java/pitest/test/LibraryTest.java | 7 +++++++ .../gradle/pitest/PitestPlugin.groovy | 19 ++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/funcTest/groovy/pl/droidsonroids/gradle/pitest/functional/MockableAndroidJarFunctionalSpec.groovy b/src/funcTest/groovy/pl/droidsonroids/gradle/pitest/functional/MockableAndroidJarFunctionalSpec.groovy index 312e01e3..32888194 100644 --- a/src/funcTest/groovy/pl/droidsonroids/gradle/pitest/functional/MockableAndroidJarFunctionalSpec.groovy +++ b/src/funcTest/groovy/pl/droidsonroids/gradle/pitest/functional/MockableAndroidJarFunctionalSpec.groovy @@ -50,6 +50,7 @@ class MockableAndroidJarFunctionalSpec extends AbstractPitestFunctionalSpec { dependencies { testImplementation 'junit:junit:4.13.2' + testImplementation 'org.json:json:20180813' } """.stripIndent() and: diff --git a/src/funcTest/resources/testProjects/mockableAndroidJar/src/test/java/pitest/test/LibraryTest.java b/src/funcTest/resources/testProjects/mockableAndroidJar/src/test/java/pitest/test/LibraryTest.java index e85e86aa..397a1741 100644 --- a/src/funcTest/resources/testProjects/mockableAndroidJar/src/test/java/pitest/test/LibraryTest.java +++ b/src/funcTest/resources/testProjects/mockableAndroidJar/src/test/java/pitest/test/LibraryTest.java @@ -3,6 +3,7 @@ import org.junit.Test; import pitest.test.Library; +import org.json.JSONObject; import static org.junit.Assert.*; @@ -12,4 +13,10 @@ public void testSomeLibraryMethod() { Library classUnderTest = new Library(); assertTrue("someLibraryMethod should return 'true'", classUnderTest.someLibraryMethod()); } + + @Test + public void testJSON() throws Exception { + JSONObject jsonObject = new JSONObject("{\"id\": 123}"); + assertEquals("123", jsonObject.optString("id")); + } } diff --git a/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy index 71d6280c..99be027c 100644 --- a/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy @@ -144,6 +144,11 @@ class PitestPlugin implements Plugin { variants.all { BaseVariant variant -> PitestTask variantTask = project.tasks.create("${PITEST_TASK_NAME}${variant.name.capitalize()}", PitestTask) + boolean includeMockableAndroidJar = !pitestExtension.excludeMockableAndroidJar.getOrElse(false) + if (includeMockableAndroidJar) { + addMockableAndroidJarDependencies() + } + Task mockableAndroidJarTask if (ANDROID_GRADLE_PLUGIN_VERSION_NUMBER < new Semver("3.2.0")) { mockableAndroidJarTask = project.tasks.findByName("mockableAndroidJar") @@ -153,7 +158,7 @@ class PitestPlugin implements Plugin { configureTaskDefault(variantTask, variant, mockableAndroidJarTask.outputJar) } - if (!pitestExtension.excludeMockableAndroidJar.getOrElse(false)) { + if (includeMockableAndroidJar) { variantTask.dependsOn mockableAndroidJarTask } @@ -169,6 +174,18 @@ class PitestPlugin implements Plugin { } } + private void addMockableAndroidJarDependencies() { + //according to https://search.maven.org/artifact/com.google.android/android/4.1.1.4/jar + project.buildscript.dependencies { + "$PITEST_TEST_COMPILE_CONFIGURATION_NAME" "org.json:json:20080701" + "$PITEST_TEST_COMPILE_CONFIGURATION_NAME" "xpp3:xpp3:1.1.4c" + "$PITEST_TEST_COMPILE_CONFIGURATION_NAME" "xerces:xmlParserAPIs:2.6.2" + "$PITEST_TEST_COMPILE_CONFIGURATION_NAME" "org.khronos:opengl-api:gl1.1-android-2.1_r1" + "$PITEST_TEST_COMPILE_CONFIGURATION_NAME" "org.apache.httpcomponents:httpclient:4.0.1" + "$PITEST_TEST_COMPILE_CONFIGURATION_NAME" "commons-logging:commons-logging:1.1.1" + } + } + @SuppressWarnings("BuilderMethodWithSideEffects") private void createConfigurations() { [PITEST_CONFIGURATION_NAME, PITEST_TEST_COMPILE_CONFIGURATION_NAME].each { configuration ->