Skip to content

Commit

Permalink
enable custom pitest versions to be used in ScmTask
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Priadka committed Dec 11, 2017
1 parent b5e8592 commit 8b40dfa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import info.solidsoft.gradle.pitest.extension.ScmPitestPluginExtension
import info.solidsoft.gradle.pitest.task.AbstractPitestTask
import info.solidsoft.gradle.pitest.task.PitestTask
import info.solidsoft.gradle.pitest.task.ScmPitestTask
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.FileCollection
Expand All @@ -37,7 +36,6 @@ import org.gradle.api.plugins.JavaBasePlugin
class PitestPlugin implements Plugin<Project> {
public final static String DEFAULT_PITEST_VERSION = '1.2.2'
public final static String PITEST_TASK_GROUP = "Report"
public final static String PITEST_TASK_NAME = "pitest"

private final static List<String> DYNAMIC_LIBRARY_EXTENSIONS = ['so', 'dll', 'dylib']
private final static List<String> FILE_EXTENSIONS_TO_FILTER_FROM_CLASSPATH = ['pom'] + DYNAMIC_LIBRARY_EXTENSIONS
Expand All @@ -60,6 +58,7 @@ class PitestPlugin implements Plugin<Project> {
this.project = project
applyRequiredJavaPlugin()
createPitestConfiguration()
createScmPitestConfiguration()
pitestExtension = project.extensions.create(PluginConstants.PITEST_EXTENSION_NAME, PitestPluginExtension, project)
scmPitestExtension = project.extensions.create(PluginConstants.SCM_PITEST_EXTENSION_NAME, ScmPitestPluginExtension, project)
project.plugins.withType(JavaBasePlugin) {
Expand All @@ -71,7 +70,8 @@ class PitestPlugin implements Plugin<Project> {
project.afterEvaluate {
pitestTask.dependsOn(calculateTasksToDependOn())
scmPitestTask.dependsOn(calculateTasksToDependOn())
addPitestCommandLineToConfiguration()
addPitestCommandLineToPitestConfiguration()
addPitestCommandLineToScmPitestConfiguration()
}
}

Expand All @@ -88,6 +88,13 @@ class PitestPlugin implements Plugin<Project> {
}
}

private void createScmPitestConfiguration() {
project.rootProject.buildscript.configurations.maybeCreate(PluginConstants.SCM_PITEST_CONFIGURATION_NAME).with {
visible = false
description = "The Pitest libraries to be used for this project."
}
}

private void configureScmTaskFromExtension(ScmPitestTask task, ScmPitestPluginExtension extension) {
configurePitestTaskFromExtension(task, extension)
task.conventionMapping.with {
Expand All @@ -101,6 +108,7 @@ class PitestPlugin implements Plugin<Project> {
endVersionType = { extension.endVersionType }
includes = {extension.includes}
managerClasspath = { extension.managerClasspath }
launchClasspath = { project.rootProject.buildscript.configurations[PluginConstants.SCM_PITEST_CONFIGURATION_NAME] }
}
}

Expand Down Expand Up @@ -198,8 +206,16 @@ class PitestPlugin implements Plugin<Project> {
}

@CompileStatic
private void addPitestCommandLineToConfiguration() {
private void addPitestCommandLineToPitestConfiguration() {
log.info("Using PIT: $pitestExtension.pitestVersion")
project.rootProject.buildscript.dependencies.add(PluginConstants.PITEST_CONFIGURATION_NAME, "org.pitest:pitest-command-line:$pitestExtension.pitestVersion")
project.rootProject.buildscript.dependencies.add(PluginConstants.PITEST_CONFIGURATION_NAME,
"org.pitest:pitest-command-line:$pitestExtension.pitestVersion")
}

@CompileStatic
private void addPitestCommandLineToScmPitestConfiguration() {
log.info("Using PIT: $scmPitestExtension.pitestVersion")
project.rootProject.buildscript.dependencies.add(PluginConstants.SCM_PITEST_CONFIGURATION_NAME,
"org.pitest:pitest-command-line:$scmPitestExtension.pitestVersion")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ interface PluginConstants {
String PITEST_EXTENSION_NAME = "pitest"
String SCM_PITEST_EXTENSION_NAME = "scmPitest"
String PITEST_CONFIGURATION_NAME = "pitest"
String SCM_PITEST_CONFIGURATION_NAME = "scmPitest"
}

0 comments on commit 8b40dfa

Please sign in to comment.