Skip to content

Commit

Permalink
Change additional classpath building
Browse files Browse the repository at this point in the history
Fixes #112
  • Loading branch information
koral-- committed Nov 12, 2023
1 parent 7230ce0 commit 4096eff
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ class PitestPlugin implements Plugin<Project> {

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"])
Expand All @@ -225,9 +225,10 @@ class PitestPlugin implements Plugin<Project> {
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}"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<File> 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)')
Expand Down

0 comments on commit 4096eff

Please sign in to comment.