diff --git a/pitmutationmate-override-plugin/plugin/build.gradle.kts b/pitmutationmate-override-plugin/plugin/build.gradle.kts index 28ed7301..3c087317 100644 --- a/pitmutationmate-override-plugin/plugin/build.gradle.kts +++ b/pitmutationmate-override-plugin/plugin/build.gradle.kts @@ -48,7 +48,7 @@ gradlePlugin { listOf( "pitmutationmate", "pitest", "mutation", "mutation testing", "mutation testing tool", "mutation testing framework", "mutation testing gradle plugin", "mutation testing ide plugin", - "mutation testing intellij plugin", "mutation testing intellij idea plugin", + "mutation testing intellij plugin", "mutation testing intellij idea plugin" ) implementationClass = "io.github.amosproj.pitmutationmate.override.PITSettingOverridePlugin" } diff --git a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/PITConfigurationValues.groovy b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/PITConfigurationValues.groovy index 5208e34f..3614ed94 100644 --- a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/PITConfigurationValues.groovy +++ b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/PITConfigurationValues.groovy @@ -6,14 +6,18 @@ package io.github.amosproj.pitmutationmate.override import org.gradle.api.file.Directory +/** + * Configuration values for the PIT plugin. + */ class PITConfigurationValues { + Integer threads = 4 boolean verbose = true boolean includeLaunchClasspath = true boolean timestampedReports = true - Set targetClasses = ["test", "test2"] - Set targetTests = ["test", "test2"] - Set outputFormats = ["XML", "HTML"] - Directory reportDir = new File("build/reports/pitest") as Directory -} + Set targetClasses = ['test1', 'test2'] + Set targetTests = ['test3', 'test4'] + Set outputFormats = ['XML', 'HTML'] + Directory reportDir = new File('build/reports/pitest') as Directory // groovylint-disable-line +} diff --git a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/PITSettingOverridePlugin.groovy b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/PITSettingOverridePlugin.groovy index 66213d14..d83e8ce0 100644 --- a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/PITSettingOverridePlugin.groovy +++ b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/PITSettingOverridePlugin.groovy @@ -2,9 +2,6 @@ // // SPDX-License-Identifier: MIT -/* - * This Groovy source file was generated by the Gradle 'init' task. - */ package io.github.amosproj.pitmutationmate.override import io.github.amosproj.pitmutationmate.override.reader.OverrideReader @@ -20,6 +17,7 @@ import org.gradle.api.logging.Logging * Partner Plugin to the PITmutationmate Plugin to allow overriding of specific PITest configuration values. */ class PITSettingOverridePlugin implements Plugin { + @SuppressWarnings("FieldName") private final static Logger log = Logging.getLogger(PITSettingOverridePlugin) @@ -36,5 +34,5 @@ class PITSettingOverridePlugin implements Plugin { } } } -} +} diff --git a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/converter/NaiveTypeConverter.groovy b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/converter/NaiveTypeConverter.groovy index d34df8f6..67776b86 100644 --- a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/converter/NaiveTypeConverter.groovy +++ b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/converter/NaiveTypeConverter.groovy @@ -12,14 +12,23 @@ import org.gradle.api.file.Directory import org.gradle.api.logging.Logger import org.gradle.api.logging.Logging +/** + * NaiveTypeConverter + * + * This class is responsible for converting a string value to a given type. + * It is used by the [PITSettingOverridePlugin] to convert the values of the + * gradle-pitest-plugin extension to the correct type. + * + * @see [PITSettingOverridePlugin] + */ class NaiveTypeConverter implements TypeConverter { - @SuppressWarnings("FieldName") + + @SuppressWarnings('FieldName') private final static Logger log = Logging.getLogger(PITSettingOverridePlugin) private final ConvertUtilsBean convertUtilsBean = new ConvertUtilsBean() @Override Object convert(String value, Class clazz, Project project) { - switch (clazz) { case Integer: log.trace("Converting Integer value '$value' to type '$clazz'.") @@ -66,6 +75,7 @@ class NaiveTypeConverter implements TypeConverter { } value = value.replace('[', '') .replace(']', '') - return value.split(",").collect { it.trim() } + return value.split(',')*.trim() } + } diff --git a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/converter/TypeConverter.groovy b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/converter/TypeConverter.groovy index 9fb35d55..90d2d2d2 100644 --- a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/converter/TypeConverter.groovy +++ b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/converter/TypeConverter.groovy @@ -6,6 +6,17 @@ package io.github.amosproj.pitmutationmate.override.converter import org.gradle.api.Project +/** + * TypeConverter + * + * This interface is responsible for converting a string value to a given type. + * It is used by the [PITSettingOverridePlugin] to convert the values of the + * gradle-pitest-plugin extension to the correct type. + * + * @see [PITSettingOverridePlugin] + */ interface TypeConverter { + Object convert(String value, Class clazz, Project project) + } diff --git a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/reader/OverrideReader.groovy b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/reader/OverrideReader.groovy index 3468bf3f..72ca5b9a 100644 --- a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/reader/OverrideReader.groovy +++ b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/reader/OverrideReader.groovy @@ -4,6 +4,17 @@ package io.github.amosproj.pitmutationmate.override.reader +/** + * OverrideReader + * + * This interface is responsible for reading the override properties. + * It is used by the [PITSettingOverridePlugin] to read the values of the + * gradle-pitest-plugin extension. + * + * @see [PITSettingOverridePlugin] + */ interface OverrideReader { + Map parseProperties() + } diff --git a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/reader/SystemPropertyOverrideReader.groovy b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/reader/SystemPropertyOverrideReader.groovy index 6da4abae..cd6e3ac6 100644 --- a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/reader/SystemPropertyOverrideReader.groovy +++ b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/reader/SystemPropertyOverrideReader.groovy @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2023 Netflix, Inc. // // SPDX-License-Identifier: Apache-2.0 +// +// Modified by Lennart Heimbs, 2023 package io.github.amosproj.pitmutationmate.override.reader @@ -14,6 +16,7 @@ package io.github.amosproj.pitmutationmate.override.reader * */ class SystemPropertyOverrideReader implements OverrideReader { + static final String OVERRIDE_PROPERTY_PREFIX = 'pitmutationmate.override.' /** @@ -23,8 +26,10 @@ class SystemPropertyOverrideReader implements OverrideReader { */ @Override Map parseProperties() { - def overrideProperties = System.properties.findAll { property -> property.key.startsWith(OVERRIDE_PROPERTY_PREFIX) } + def overrideProperties = System.properties.findAll { property -> + property.key.startsWith(OVERRIDE_PROPERTY_PREFIX) } // Remove property prefix - overrideProperties.collectEntries { key, value -> [key - OVERRIDE_PROPERTY_PREFIX, value] } + return overrideProperties.collectEntries { key, value -> [key - OVERRIDE_PROPERTY_PREFIX, value] } } + } diff --git a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/strategy/GradlePitestPluginOverrideStrategy.groovy b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/strategy/GradlePitestPluginOverrideStrategy.groovy index b9329aff..80ef9b26 100644 --- a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/strategy/GradlePitestPluginOverrideStrategy.groovy +++ b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/strategy/GradlePitestPluginOverrideStrategy.groovy @@ -13,8 +13,20 @@ import org.gradle.api.Project import org.gradle.api.logging.Logger import org.gradle.api.logging.Logging +/** + * GradlePitestPluginOverrideStrategy + * + * This class is responsible for overriding the properties of the gradle-pitest-plugin. + * It is used by the [PITSettingOverridePlugin] to override the values of the + * gradle-pitest-plugin extension. + * + * @see [PITSettingOverridePlugin] + */ class GradlePitestPluginOverrideStrategy implements OverrideStrategy { - @SuppressWarnings("FieldName") + + static final String OVERRIDE_SECTION = 'pitest' + + @SuppressWarnings('FieldName') private final static Logger log = Logging.getLogger(PITSettingOverridePlugin) TypeConverter typeConverter = new NaiveTypeConverter() as TypeConverter @@ -22,7 +34,7 @@ class GradlePitestPluginOverrideStrategy implements OverrideStrategy { void apply(Project project, String propertyName, String overrideValue) { log.debug("Overriding property '$propertyName' with '$overrideValue'.") - def pitestExtension = project.extensions.findByName("pitest") + def pitestExtension = project.extensions.findByName(OVERRIDE_SECTION) if (pitestExtension == null) { throw new GradleException("PITest extension not found. Please apply the PITest plugin first.") } @@ -34,7 +46,8 @@ class GradlePitestPluginOverrideStrategy implements OverrideStrategy { PITConfigurationValues overrideFields = new PITConfigurationValues() def overrideProperty = overrideFields.properties.find { it.key == propertyName } if (overrideProperty == null) { - throw new GradleException("Cannot override property '$propertyName' for pitest extension: Unknown Property.") + throw new GradleException( + "Cannot override property '$propertyName' for pitest extension: Unknown Property.") } Class clazz = overrideProperty.value.getClass() @@ -43,5 +56,5 @@ class GradlePitestPluginOverrideStrategy implements OverrideStrategy { log.debug("Property '$propertyName' successfully overwritten with '$newValue'.") } -} +} diff --git a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/strategy/OverrideStrategy.groovy b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/strategy/OverrideStrategy.groovy index b7462a9f..d5e74805 100644 --- a/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/strategy/OverrideStrategy.groovy +++ b/pitmutationmate-override-plugin/plugin/src/main/groovy/io/github/amosproj/pitmutationmate/override/strategy/OverrideStrategy.groovy @@ -6,6 +6,17 @@ package io.github.amosproj.pitmutationmate.override.strategy import org.gradle.api.Project +/** + * OverrideStrategy + * + * This interface is responsible for applying the override value to the gradle-pitest-plugin extension. + * It is used by the [PITSettingOverridePlugin] to apply the values of the + * gradle-pitest-plugin extension. + * + * @see [PITSettingOverridePlugin] + */ interface OverrideStrategy { + void apply(Project project, String propertyName, String overrideValue) + } diff --git a/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/BaseOverridePluginIntegrationTest.groovy b/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/BaseOverridePluginIntegrationTest.groovy deleted file mode 100644 index 9c08ac36..00000000 --- a/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/BaseOverridePluginIntegrationTest.groovy +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Netflix, Inc. -// -// SPDX-License-Identifier: Apache-2.0 - -package io.github.amosproj.pitmutationmate.override - -import nebula.test.IntegrationSpec - -abstract class BaseOverridePluginIntegrationTest extends IntegrationSpec { - - def setup() { - buildFile << """ - apply plugin: 'io.github.amosproj.pitmutationmate.override' - """ - } -} diff --git a/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/TypesPropertyIntegrationTest.groovy b/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/TypesPropertyIntegrationTest.groovy index 40eda3bc..1ea25e2c 100644 --- a/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/TypesPropertyIntegrationTest.groovy +++ b/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/TypesPropertyIntegrationTest.groovy @@ -5,12 +5,28 @@ // Modifications by: Lennart Heimbs // - Adapt to pitest specific use case +/* groovylint-disable */ + package io.github.amosproj.pitmutationmate.override +import nebula.test.IntegrationSpec import nebula.test.functional.internal.toolingapi.ToolingExecutionResult +import org.gradle.api.logging.LogLevel import spock.lang.Unroll -class TypesPropertyIntegrationTest extends BaseOverridePluginIntegrationTest { +/** + * Integration tests for the plugin. + */ +class TypesPropertyIntegrationTest extends IntegrationSpec { + + /* groovylint-disable JUnitPublicNonTestMethod, MethodReturnTypeRequired, NoDef */ + def setup() { + logLevel = LogLevel.DEBUG + fork = true + buildFile << """ + apply plugin: 'io.github.amosproj.pitmutationmate.override' + """ + } @Unroll("'#commandLineParameter' should be converted to '#expectedValue'") def "Should allow to override Set property"() { diff --git a/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/converter/NaiveTypeConverterTest.groovy b/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/converter/NaiveTypeConverterTest.groovy index a134beae..7d25cbe2 100644 --- a/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/converter/NaiveTypeConverterTest.groovy +++ b/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/converter/NaiveTypeConverterTest.groovy @@ -4,10 +4,18 @@ package io.github.amosproj.pitmutationmate.override.converter - import spock.lang.Specification import spock.lang.Unroll +/* groovylint-disable JUnitPublicNonTestMethod, MethodName */ + +/** + * NaiveTypeConverterTest + * + * This class is responsible for testing the [NaiveTypeConverter]. + * + * @see [NaiveTypeConverter] + */ class NaiveTypeConverterTest extends Specification { @Unroll @@ -77,7 +85,8 @@ class NaiveTypeConverterTest extends Specification { 'false' | 'boolean' || false '1' | 'integer' || 1 '999' | 'integer' || 999 - 'foobar' | 'string' || 'foobar' as String - '9999999999999.999' | 'BigDec' || new BigDecimal('9999999999999.999') + 'foobar' | 'string' || 'foobar' + '9999999999999.999' | 'BigDec' || 9999999999999.999G } + } diff --git a/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/strategy/GradlePitestPluginOverrideStrategyTest.groovy b/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/strategy/GradlePitestPluginOverrideStrategyTest.groovy index 8454b8dc..c3225246 100644 --- a/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/strategy/GradlePitestPluginOverrideStrategyTest.groovy +++ b/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/strategy/GradlePitestPluginOverrideStrategyTest.groovy @@ -5,15 +5,24 @@ // Modifications by: Lennart Heimbs // - Adapt to pitest specific use case +/* groovylint-disable JUnitPublicNonTestMethod, MethodName */ + package io.github.amosproj.pitmutationmate.override.strategy import io.github.amosproj.pitmutationmate.override.PITConfigurationValues import nebula.test.ProjectSpec import org.gradle.api.GradleException +import org.gradle.api.file.Directory +/** + * Tests for [GradlePitestPluginOverrideStrategy]. + */ class GradlePitestPluginOverrideStrategyTest extends ProjectSpec { - OverrideStrategy overrideStrategy = new GradlePitestPluginOverrideStrategy() + def "Throws exception if pitest extension cannot be resolved"() { + given: + OverrideStrategy overrideStrategy = new GradlePitestPluginOverrideStrategy() + when: overrideStrategy.apply(project, 'doesntExist', 'test') @@ -23,75 +32,81 @@ class GradlePitestPluginOverrideStrategyTest extends ProjectSpec { } def "Throws exception if extension does not have property"() { - given: - project.extensions.add('pitest', new Object()) + given: + OverrideStrategy overrideStrategy = new GradlePitestPluginOverrideStrategy() + project.extensions.add('pitest', new Object()) - when: - overrideStrategy.apply(project, 'doesntExist', 'test') + when: + overrideStrategy.apply(project, 'doesntExist', 'test') - then: - Throwable t = thrown(GradleException) - t.message == "Unknown property with name 'doesntExist' for pitest extension." + then: + Throwable t = thrown(GradleException) + t.message == "Unknown property with name 'doesntExist' for pitest extension." } def "Throws exception if PITConfigurationValues does not have property"() { - given: - project.extensions.create('pitest', PitestSampleFailingExtension) + given: + OverrideStrategy overrideStrategy = new GradlePitestPluginOverrideStrategy() + project.extensions.create('pitest', PitestSampleFailingExtension) - when: - overrideStrategy.apply(project, 'doesntExist', 'test') + when: + overrideStrategy.apply(project, 'doesntExist', 'test') - then: - Throwable t = thrown(GradleException) - t.message == "Cannot override property 'doesntExist' for pitest extension: Unknown Property." + then: + Throwable t = thrown(GradleException) + t.message == "Cannot override property 'doesntExist' for pitest extension: Unknown Property." } def "Can override pitest property threads"() { - given: - project.extensions.create('pitest', PITConfigurationValues) - assert project.pitest.threads == 4 + given: + OverrideStrategy overrideStrategy = new GradlePitestPluginOverrideStrategy() + project.extensions.create('pitest', PITConfigurationValues) + assert project.pitest.threads == 4 - when: - overrideStrategy.apply(project, 'threads', '8') + when: + overrideStrategy.apply(project, 'threads', '8') - then: - project.pitest.threads == 8 + then: + project.pitest.threads == 8 } def "Can override pitest property verbose"() { - given: - project.extensions.create('pitest', PITConfigurationValues) - assert project.pitest.verbose == true + given: + OverrideStrategy overrideStrategy = new GradlePitestPluginOverrideStrategy() + project.extensions.create('pitest', PITConfigurationValues) + assert project.pitest.verbose == true - when: - overrideStrategy.apply(project, 'verbose', 'false') + when: + overrideStrategy.apply(project, 'verbose', 'false') - then: - project.pitest.verbose == false + then: + project.pitest.verbose == false } def "Can override pitest property includeLaunchClasspath"() { - given: - project.extensions.create('pitest', PITConfigurationValues) - assert project.pitest.includeLaunchClasspath == true + given: + OverrideStrategy overrideStrategy = new GradlePitestPluginOverrideStrategy() + project.extensions.create('pitest', PITConfigurationValues) + assert project.pitest.includeLaunchClasspath == true - when: - overrideStrategy.apply(project, 'includeLaunchClasspath', 'false') + when: + overrideStrategy.apply(project, 'includeLaunchClasspath', 'false') - then: - project.pitest.includeLaunchClasspath == false + then: + project.pitest.includeLaunchClasspath == false } def "Can override pitest property timestampedReports"() { - given: - project.extensions.create('pitest', PITConfigurationValues) - assert project.pitest.timestampedReports == true + given: + OverrideStrategy overrideStrategy = new GradlePitestPluginOverrideStrategy() + project.extensions.create('pitest', PITConfigurationValues) + assert project.pitest.timestampedReports == true - when: - overrideStrategy.apply(project, 'timestampedReports', 'false') + when: + overrideStrategy.apply(project, 'timestampedReports', 'false') - then: - project.pitest.timestampedReports == false + then: + project.pitest.timestampedReports == false } def "Can override pitest property targetClasses"() { @@ -100,11 +115,11 @@ class GradlePitestPluginOverrideStrategyTest extends ProjectSpec { project.extensions.create('pitest', PITConfigurationValues) assert project.pitest.targetClasses == [ "test1", "test2" ].toSet() - when: - overrideStrategy.apply(project, 'targetClasses', 'good1,good2') + when: + overrideStrategy.apply(project, 'targetClasses', 'good1,good2') - then: - project.pitest.targetClasses == ['good1', 'good2'].toSet() + then: + project.pitest.targetClasses == ['good1', 'good2'].toSet() } def "Can override pitest property targetTests"() { @@ -113,40 +128,45 @@ class GradlePitestPluginOverrideStrategyTest extends ProjectSpec { project.extensions.create('pitest', PITConfigurationValues) assert project.pitest.targetTests == [ "test3", "test4" ].toSet() - when: - overrideStrategy.apply(project, 'targetTests', 'good1,good2') + when: + overrideStrategy.apply(project, 'targetTests', 'good1,good2') - then: - project.pitest.targetTests == ['good1', 'good2'].toSet() + then: + project.pitest.targetTests == ['good1', 'good2'].toSet() } def "Can override pitest property outputFormats"() { - given: - project.extensions.create('pitest', PITConfigurationValues) - assert project.pitest.outputFormats == [ "XML", "HTML" ].toSet() + given: + OverrideStrategy overrideStrategy = new GradlePitestPluginOverrideStrategy() + project.extensions.create('pitest', PITConfigurationValues) + assert project.pitest.outputFormats == [ "XML", "HTML" ].toSet() - when: - overrideStrategy.apply(project, 'outputFormats', 'good1,good2') + when: + overrideStrategy.apply(project, 'outputFormats', 'good1,good2') - then: - project.pitest.outputFormats == ['good1', 'good2'].toSet() + then: + project.pitest.outputFormats == ['good1', 'good2'].toSet() } def "Can override pitest property reportDir"() { - given: - project.extensions.create('pitest', PITConfigurationValues) - def givenDir = new File("build/reports/pitest") as Directory - def newDir = new File("/tmp/test") as Directory - assert project.pitest.reportDir.absolutePath == givenDir.absolutePath + given: + OverrideStrategy overrideStrategy = new GradlePitestPluginOverrideStrategy() + project.extensions.create('pitest', PITConfigurationValues) + def givenDir = new File("build/reports/pitest") as Directory + def newDir = new File("/tmp/test") as Directory + assert project.pitest.reportDir.absolutePath == givenDir.absolutePath - when: - overrideStrategy.apply(project, 'reportDir', '/tmp/test') + when: + overrideStrategy.apply(project, 'reportDir', '/tmp/test') - then: - project.pitest.reportDir.toString() == newDir.absolutePath + then: + project.pitest.reportDir.toString() == newDir.absolutePath } + } class PitestSampleFailingExtension { + String doesntExist + } diff --git a/pitmutationmate/build.gradle.kts b/pitmutationmate/build.gradle.kts index 704d3cfa..31993cbf 100644 --- a/pitmutationmate/build.gradle.kts +++ b/pitmutationmate/build.gradle.kts @@ -2,67 +2,67 @@ // SPDX-FileCopyrightText: 2023 plugins { - id("java") - id("org.jetbrains.kotlin.jvm") version "1.9.0" - id("org.jetbrains.intellij") version "1.15.0" - id("info.solidsoft.pitest") version "1.15.0" + id("java") + id("org.jetbrains.kotlin.jvm") version "1.9.0" + id("org.jetbrains.intellij") version "1.15.0" + id("info.solidsoft.pitest") version "1.15.0" } tasks.test { - useJUnitPlatform() + useJUnitPlatform() } dependencies { - implementation("org.pitest:pitest-command-line:1.7.0") - implementation("org.junit.jupiter:junit-jupiter:5.8.1") - implementation("org.junit.jupiter:junit-jupiter:5.8.1") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1") - // https://mvnrepository.com/artifact/org.jfree/jfreechart - implementation("org.jfree:jfreechart:1.0.19") - // https://mvnrepository.com/artifact/jfree/jcommon - implementation("org.jfree:jcommon:1.0.24") - implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.0") + implementation("org.pitest:pitest-command-line:1.7.0") + implementation("org.junit.jupiter:junit-jupiter:5.8.1") + implementation("org.junit.jupiter:junit-jupiter:5.8.1") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1") + // https://mvnrepository.com/artifact/org.jfree/jfreechart + implementation("org.jfree:jfreechart:1.0.19") + // https://mvnrepository.com/artifact/jfree/jcommon + implementation("org.jfree:jcommon:1.0.24") + implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.0") } group = "com.amos.pitmutationmate" version = "1.0-SNAPSHOT" repositories { - mavenCentral() + mavenCentral() } // Configure Gradle IntelliJ Plugin // Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") - type.set("IC") // Target IDE Platform + version.set("2022.2.5") + type.set("IC") // Target IDE Platform - plugins.set(listOf("org.jetbrains.kotlin", "com.intellij.java")) + plugins.set(listOf("org.jetbrains.kotlin", "com.intellij.java")) } tasks { - // Set the JVM compatibility versions - withType { - sourceCompatibility = "17" - targetCompatibility = "17" - } - withType { - kotlinOptions.jvmTarget = "17" - } + // Set the JVM compatibility versions + withType { + sourceCompatibility = "17" + targetCompatibility = "17" + } + withType { + kotlinOptions.jvmTarget = "17" + } - patchPluginXml { - sinceBuild.set("222") - untilBuild.set("232.*") - } + patchPluginXml { + sinceBuild.set("222") + untilBuild.set("232.*") + } - signPlugin { - certificateChain.set(System.getenv("CERTIFICATE_CHAIN")) - privateKey.set(System.getenv("PRIVATE_KEY")) - password.set(System.getenv("PRIVATE_KEY_PASSWORD")) - } + signPlugin { + certificateChain.set(System.getenv("CERTIFICATE_CHAIN")) + privateKey.set(System.getenv("PRIVATE_KEY")) + password.set(System.getenv("PRIVATE_KEY_PASSWORD")) + } - publishPlugin { - token.set(System.getenv("PUBLISH_TOKEN")) - } + publishPlugin { + token.set(System.getenv("PUBLISH_TOKEN")) + } } diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/actions/ToolMenuAction.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/actions/ToolMenuAction.kt index 56590f71..786522f9 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/actions/ToolMenuAction.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/actions/ToolMenuAction.kt @@ -40,7 +40,6 @@ class ToolMenuAction : AnAction() { } } - override fun update(e: AnActionEvent) { super.update(e) } diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/ConfigurationFactory.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/ConfigurationFactory.kt index 3387e6c9..5c071825 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/ConfigurationFactory.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/ConfigurationFactory.kt @@ -9,16 +9,16 @@ import com.intellij.execution.configurations.RunConfiguration import com.intellij.openapi.components.BaseState import com.intellij.openapi.project.Project -class MutationMateConfigurationFactory(type: ConfigurationType?) : ConfigurationFactory(type!!) { +class ConfigurationFactory(type: ConfigurationType?) : ConfigurationFactory(type!!) { override fun getId(): String { - return MutationMateRunConfigurationType.ID + return RunConfigurationType.ID } override fun createTemplateConfiguration(project: Project): RunConfiguration { - return MutationMateRunConfiguration(project, this, "PITmutationmate") + return RunConfiguration(project, this, "PITmutationmate") } override fun getOptionsClass(): Class { - return MutationMateRunConfigurationOptions::class.java + return RunConfigurationOptions::class.java } } diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/RunConfiguration.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/RunConfiguration.kt index 7839157e..d373ca28 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/RunConfiguration.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/RunConfiguration.kt @@ -7,7 +7,11 @@ import com.amos.pitmutationmate.pitmutationmate.execution.GradleTaskExecutor import com.amos.pitmutationmate.pitmutationmate.execution.MavenTaskExecutor import com.intellij.execution.ExecutionException import com.intellij.execution.Executor -import com.intellij.execution.configurations.* +import com.intellij.execution.configurations.CommandLineState +import com.intellij.execution.configurations.ConfigurationFactory +import com.intellij.execution.configurations.RunConfiguration +import com.intellij.execution.configurations.RunConfigurationBase +import com.intellij.execution.configurations.RunProfileState import com.intellij.execution.process.ProcessHandler import com.intellij.execution.runners.ExecutionEnvironment import com.intellij.openapi.externalSystem.ExternalSystemModulePropertyManager @@ -16,19 +20,19 @@ import com.intellij.openapi.options.SettingsEditor import com.intellij.openapi.project.Project import org.jetbrains.annotations.NotNull -class MutationMateRunConfiguration( +class RunConfiguration( project: Project, factory: ConfigurationFactory?, name: String? -) : RunConfigurationBase(project, factory, name) { +) : RunConfigurationBase(project, factory, name) { private val projectDir: String init { projectDir = project.basePath!! } - override fun getOptions(): MutationMateRunConfigurationOptions { - return super.getOptions() as MutationMateRunConfigurationOptions + override fun getOptions(): RunConfigurationOptions { + return super.getOptions() as RunConfigurationOptions } var taskName: String? @@ -51,7 +55,7 @@ class MutationMateRunConfiguration( } override fun getConfigurationEditor(): SettingsEditor { - return MutationMateSettingsEditor() + return com.amos.pitmutationmate.pitmutationmate.configuration.SettingsEditor() } override fun getState( diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/RunConfigurationType.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/RunConfigurationType.kt index 62c0d24f..bd403458 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/RunConfigurationType.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/RunConfigurationType.kt @@ -7,9 +7,12 @@ import com.intellij.execution.configurations.ConfigurationTypeBase import com.intellij.icons.AllIcons import com.intellij.openapi.util.NotNullLazyValue -internal class MutationMateRunConfigurationType : ConfigurationTypeBase( - ID, "PITmutationmate", "PITmutationmate run configuration type", - NotNullLazyValue.createValue { AllIcons.Nodes.Console }) { +internal class RunConfigurationType : ConfigurationTypeBase( + ID, + "PITmutationmate", + "PITmutationmate run configuration type", + NotNullLazyValue.createValue { AllIcons.Nodes.Console } +) { init { addFactory(ConfigurationFactory(this)) } diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/SettingsEditor.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/SettingsEditor.kt index 9738c5bd..989267d5 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/SettingsEditor.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/configuration/SettingsEditor.kt @@ -18,12 +18,17 @@ class SettingsEditor : SettingsEditor() { init { gradleTaskField.text = "pitest" - gradleExecutableField.addBrowseFolderListener("Select Gradle Script", null, null, - FileChooserDescriptorFactory.createSingleFileDescriptor()); - myPanel = FormBuilder.createFormBuilder() - .addLabeledComponent("Gradle task", gradleTaskField) - .addLabeledComponent("Gradle script", gradleExecutableField) - .panel + gradleExecutableField.addBrowseFolderListener( + "Select Gradle Script", + null, + null, + FileChooserDescriptorFactory.createSingleFileDescriptor() + ) + myPanel = + FormBuilder.createFormBuilder() + .addLabeledComponent("Gradle task", gradleTaskField) + .addLabeledComponent("Gradle script", gradleExecutableField) + .panel } override fun resetEditorFrom(runConfiguration: RunConfiguration) { diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/execution/GradleTaskExecutor.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/execution/GradleTaskExecutor.kt index c83193e4..0e870b89 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/execution/GradleTaskExecutor.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/execution/GradleTaskExecutor.kt @@ -17,7 +17,7 @@ class GradleTaskExecutor : BasePitestExecutor() { executable: String?, taskName: String?, projectDir: String, - classFQN: String?, + classFQN: String? ): GeneralCommandLine { val commandLine = GeneralCommandLine() diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/execution/MavenTaskExecutor.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/execution/MavenTaskExecutor.kt index 3924253d..99daaab9 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/execution/MavenTaskExecutor.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/execution/MavenTaskExecutor.kt @@ -14,7 +14,7 @@ class MavenTaskExecutor : BasePitestExecutor() { executable: String?, taskName: String?, projectDir: String, - classFQN: String?, + classFQN: String? ): GeneralCommandLine { val commandLine = GeneralCommandLine() @@ -43,4 +43,3 @@ class MavenTaskExecutor : BasePitestExecutor() { return parameters } } -