Skip to content

Commit

Permalink
[#62] Move pitest configuration to subprojects
Browse files Browse the repository at this point in the history
To eliminate warnings in Gradle 6+.
Originally the configuration had to be created in the buildscript scope
for the root project.

Fixes #62.
  • Loading branch information
szpak committed Apr 22, 2020
1 parent cf97a8e commit 41e1ba6
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 27 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# gradle-pitest-plugin changelog

## 1.5.0 - Unreleased

- Move `pitest` configuration from root project to current project to eliminate Gradle 6+ warning - [#62](https://github.com/szpak/gradle-pitest-plugin/issues/62)

TODO: Describe migration

## 1.4.9 - 2020-04-22

- Fix regression in 1.4.8 related to missing source listing in PIT reports - [#198](https://github.com/szpak/gradle-pitest-plugin/issues/198)
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,20 @@ buildscript {
repositories {
mavenCentral()
}
configurations.maybeCreate('pitest')
dependencies {
classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.4.9'
pitest 'org.pitest:pitest-junit5-plugin:0.12'
}
}
repositories {
mavenCentral()
}
configurations.create('pitest')
dependencies {
pitest 'org.pitest:pitest-junit5-plugin:0.12'
}
pitest {
testPlugin = 'junit5' //or built-in 'testng' which also has to be activated
// ...
Expand All @@ -260,6 +267,7 @@ pitest {

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.

## Versions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@ package info.solidsoft.gradle.pitest.functional

import groovy.transform.CompileDynamic
import nebula.test.functional.ExecutionResult
import spock.util.environment.RestoreSystemProperties

@CompileDynamic
class AcceptanceTestsInSeparateSubprojectFunctionalSpec extends AbstractPitestFunctionalSpec {

@RestoreSystemProperties
void "should mutate production code in another subproject"() {
given:
copyResources("testProjects/multiproject", "")
and:
//For Gradle 6+, until fixed: https://github.com/szpak/gradle-pitest-plugin/issues/62
System.setProperty("ignoreDeprecations", "true")
when:
ExecutionResult result = runTasksSuccessfully('pitest')
then:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ class PitestPluginGeneralFunctionalSpec extends AbstractPitestFunctionalSpec {
given:
buildFile << getBasicGradlePitestConfig()
buildFile << """
buildscript {
repositories {
maven { url "https://dl.bintray.com/szpak/pitest-plugins/" }
}
configurations.maybeCreate("pitest")
dependencies {
pitest 'org.pitest.plugins:pitest-plugin-configuration-reporter-plugin:0.0.2'
}
repositories {
maven { url "https://dl.bintray.com/szpak/pitest-plugins/" }
}
configurations.create("pitest")
dependencies {
pitest 'org.pitest.plugins:pitest-plugin-configuration-reporter-plugin:0.0.2'
}
pitest {
excludedClasses = []
Expand Down
5 changes: 3 additions & 2 deletions src/funcTest/resources/testProjects/junit5kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ buildscript {
repositories {
mavenCentral()
}
configurations.maybeCreate("pitest")
dependencies {
// classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.2.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
pitest 'org.pitest:pitest-junit5-plugin:0.12'
}
}

Expand All @@ -27,12 +25,15 @@ repositories {
mavenCentral()
}

configurations.create("pitest")

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit5Version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version"
testImplementation "org.junit.platform:junit-platform-runner:$junitPlatformVersion"

pitest 'org.pitest:pitest-junit5-plugin:0.12'
}

compileKotlin {
Expand Down
14 changes: 9 additions & 5 deletions src/funcTest/resources/testProjects/junit5simple/build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
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()
}
configurations.maybeCreate('pitest')
dependencies {
//Local/current version of the plugin should be put on a classpath earlier to override that plugin version
// classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.1.7-SNAPSHOT'
//Not needed, 'junit5PluginVersion' should implicitly add it in requested version
// pitest 'org.pitest:pitest-junit5-plugin:0.12'
classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:X.Y.Z-SNAPSHOT'
}
}
*/

repositories {
mavenCentral()
}

dependencies {
// //Not needed, 'junit5PluginVersion' should implicitly add it in requested version
// pitest 'org.pitest:pitest-junit5-plugin:0.12'
}

group = "pitest.test"

dependencies {
Expand Down
4 changes: 2 additions & 2 deletions src/funcTest/resources/testProjects/multiproject/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ configure(project(':itest')) {
pitest {
timestampedReports = false
mainSourceSets = [project.sourceSets.main, project(':shared').sourceSets.main]
//Fails with IllegalArgumentException: Mutable Project State warnings were found - workaround applied
//Generates deprecation warning in Gradle 5.6+
//Asked for recommendation: https://discuss.gradle.org/t/accessing-other-module-dependency-files-without-mutable-project-state-warnings/35048
// additionalMutableCodePaths = configurations.mutableCodeBase.files
additionalMutableCodePaths = project(':shared').jar.outputs.files.getFiles() //Should also work
additionalMutableCodePaths = project(':shared').jar.outputs.files.getFiles() //Workaround
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ class PitestPlugin implements Plugin<Project> {
}

private Configuration configuration() {
return project.rootProject.buildscript.configurations.maybeCreate(PITEST_CONFIGURATION_NAME).with { configuration ->
return project.configurations.maybeCreate(PITEST_CONFIGURATION_NAME).with { configuration ->
visible = false
description = "The Pitest libraries to be used for this project."
description = "The PIT libraries to be used for this project."
return configuration
}
}
Expand Down Expand Up @@ -176,7 +176,7 @@ class PitestPlugin implements Plugin<Project> {
task.jvmPath.set(extension.jvmPath)
task.mainProcessJvmArgs.set(extension.mainProcessJvmArgs)
task.launchClasspath.setFrom({
project.rootProject.buildscript.configurations[PITEST_CONFIGURATION_NAME]
project.configurations[PITEST_CONFIGURATION_NAME]
} as Callable<Configuration>)
task.pluginConfiguration.set(extension.pluginConfiguration)
task.maxSurviving.set(extension.maxSurviving)
Expand Down

0 comments on commit 41e1ba6

Please sign in to comment.