From 4096eff5a9e73d6f824322c1a2cf6967d98eb98e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20Wr=C3=B3tniak?= Date: Sun, 12 Nov 2023 15:50:28 +0100 Subject: [PATCH 1/2] Change additional classpath building Fixes #112 --- .../gradle/pitest/PitestPlugin.groovy | 15 ++++++++------- .../gradle/pitest/AndroidUtils.groovy | 8 ++++++++ .../gradle/pitest/PitestPluginTest.groovy | 11 +++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy b/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy index 99be027c..ab8a09b6 100644 --- a/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy +++ b/src/main/groovy/pl/droidsonroids/gradle/pitest/PitestPlugin.groovy @@ -211,11 +211,11 @@ class PitestPlugin implements Plugin { if (ANDROID_GRADLE_PLUGIN_VERSION_NUMBER.major == 3 && project.findProperty("android.enableJetifier") != "true") { if (ANDROID_GRADLE_PLUGIN_VERSION_NUMBER.minor < 3) { - from(project.configurations["${variant.name}CompileClasspath"].copyRecursive { configuration -> - configuration.properties.dependencyProject == null + from(project.configurations["${variant.name}CompileClasspath"].copyRecursive { dependency -> + dependency.properties.dependencyProject == null }) - from(project.configurations["${variant.name}UnitTestCompileClasspath"].copyRecursive { configuration -> - configuration.properties.dependencyProject == null + from(project.configurations["${variant.name}UnitTestCompileClasspath"].copyRecursive { dependency -> + dependency.properties.dependencyProject == null }) } else if (ANDROID_GRADLE_PLUGIN_VERSION_NUMBER.minor < 4) { from(project.configurations["${variant.name}CompileClasspath"]) @@ -225,9 +225,10 @@ class PitestPlugin implements Plugin { from(project.configurations["compile"]) 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.version != null - }) + Configuration unittestRuntimeConfig = project.configurations.getByName("${variant.name}UnitTestRuntimeClasspath") + from(unittestRuntimeConfig.copyRecursive { dependency -> + dependency.properties.dependencyProject == null && dependency.version != null + }.shouldResolveConsistentlyWith(unittestRuntimeConfig)) } from(project.configurations["pitestRuntimeOnly"]) from(project.files("${project.buildDir}/intermediates/sourceFolderJavaResources/${variant.dirName}")) diff --git a/src/test/groovy/pl/droidsonroids/gradle/pitest/AndroidUtils.groovy b/src/test/groovy/pl/droidsonroids/gradle/pitest/AndroidUtils.groovy index cb812434..91b0d783 100644 --- a/src/test/groovy/pl/droidsonroids/gradle/pitest/AndroidUtils.groovy +++ b/src/test/groovy/pl/droidsonroids/gradle/pitest/AndroidUtils.groovy @@ -82,6 +82,14 @@ class AndroidUtils { unitTests.returnDefaultValues = true } } + project.dependencies { + implementation("org.jetbrains.kotlin:kotlin-reflect:1.6.10") + testImplementation("io.mockk:mockk:1.11.0") + } + project.repositories { + mavenCentral() + google() + } project.apply(plugin: "pl.droidsonroids.pitest") return project } diff --git a/src/test/groovy/pl/droidsonroids/gradle/pitest/PitestPluginTest.groovy b/src/test/groovy/pl/droidsonroids/gradle/pitest/PitestPluginTest.groovy index 564a3292..8b5bec64 100644 --- a/src/test/groovy/pl/droidsonroids/gradle/pitest/PitestPluginTest.groovy +++ b/src/test/groovy/pl/droidsonroids/gradle/pitest/PitestPluginTest.groovy @@ -87,6 +87,17 @@ class PitestPluginTest extends Specification { assert classpath.find { it.toString().endsWith('sourceFolderJavaResources/test/freeBlue/release') } } + @SuppressWarnings("ImplicitClosureParameter") + void "combined task classpath contains dependencies in correct order"() { + when: + Project project = AndroidUtils.createSampleApplicationProject() + project.evaluate() + then: + Set classpath = project.tasks["${PitestPlugin.PITEST_TASK_NAME}FreeBlueRelease"].additionalClasspath.files + assert classpath.find { it.toString().endsWith('kotlin-reflect-1.3.72.jar') } == null + assert classpath.find { it.toString().endsWith('kotlin-reflect-1.6.10.jar') } + } + void "strange sdk versions get properly sanitized"() { when: String version = PitestPlugin.sanitizeSdkVersion('strange version (0)') From 5fb80c8897579c86e893550029c58292b76fb5ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20Wr=C3=B3tniak?= Date: Sun, 12 Nov 2023 17:26:30 +0100 Subject: [PATCH 2/2] Release 0.2.15 --- CHANGELOG.md | 4 ++++ README.md | 6 +++--- gradle.properties | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58197cca..fdd9a3de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.2.15 - 2023-11-12 + +- Change additional classpath building [#112](https://github.com/koral--/gradle-pitest-plugin/issue/112) + # 0.2.14 - 2023-11-06 - Update dependency versions diff --git a/README.md b/README.md index 328a5d8d..dcce43a7 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,13 @@ which supports Android gradle projects. ```groovy plugins { - id 'pl.droidsonroids.pitest' version '0.2.14' + id 'pl.droidsonroids.pitest' version '0.2.15' } ``` ```kotlin plugins { - id("pl.droidsonroids.pitest") version "0.2.14" + id("pl.droidsonroids.pitest") version "0.2.15" } ``` @@ -25,7 +25,7 @@ buildscript { google() } dependencies { - classpath("pl.droidsonroids.gradle:gradle-pitest-plugin:0.2.14") + classpath("pl.droidsonroids.gradle:gradle-pitest-plugin:0.2.15") } } diff --git a/gradle.properties b/gradle.properties index b8bc6dbd..fd3b5996 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=0.2.14 +VERSION_NAME=0.2.15 GROUP=pl.droidsonroids.gradle POM_DESCRIPTION=Gradle plugin for PIT Mutation Testing in Android projects POM_URL=https://github.com/koral--/gradle-pitest-plugin