From 31f7877eeda9d4569d3a245537ce0d2a696022fb Mon Sep 17 00:00:00 2001 From: Constructor Date: Wed, 15 Jan 2025 20:14:00 +0100 Subject: [PATCH] TS-38628 POM cleanup and kotlin tests --- .../tia/TiaMavenCucumberSystemTest.java | 2 +- teamscale-maven-plugin/pom.xml | 93 +++++++++---------- .../com/teamscale/maven/tia/TiaMojoBase.kt | 7 +- .../maven/upload/CoverageUploadMojo.kt | 2 +- .../com/teamscale/maven/tia/ArgLineTest.java | 40 -------- .../com/teamscale/maven/tia/ArgLineTest.kt | 41 ++++++++ 6 files changed, 88 insertions(+), 97 deletions(-) delete mode 100644 teamscale-maven-plugin/src/test/java/com/teamscale/maven/tia/ArgLineTest.java create mode 100644 teamscale-maven-plugin/src/test/kotlin/com/teamscale/maven/tia/ArgLineTest.kt diff --git a/system-tests/cucumber-maven-tia/src/test/java/com/teamscale/tia/TiaMavenCucumberSystemTest.java b/system-tests/cucumber-maven-tia/src/test/java/com/teamscale/tia/TiaMavenCucumberSystemTest.java index 17952e61c..825869ed6 100644 --- a/system-tests/cucumber-maven-tia/src/test/java/com/teamscale/tia/TiaMavenCucumberSystemTest.java +++ b/system-tests/cucumber-maven-tia/src/test/java/com/teamscale/tia/TiaMavenCucumberSystemTest.java @@ -14,7 +14,7 @@ import static org.junit.jupiter.api.Assertions.assertAll; /** - * Runs several Maven projects' Surefire tests that have the agent attached and one of our JUnit run listeners enabled. + * Runs several Maven projects' Surefire tests that have the agent attached, and one of our JUnit run listeners enabled. * Checks that this produces a correct coverage report. */ public class TiaMavenCucumberSystemTest { diff --git a/teamscale-maven-plugin/pom.xml b/teamscale-maven-plugin/pom.xml index e4d52c98c..347c804a9 100644 --- a/teamscale-maven-plugin/pom.xml +++ b/teamscale-maven-plugin/pom.xml @@ -9,7 +9,6 @@ c.f. https://maven.apache.org/docs/3.2.1/release-notes.html --> ${revision} - maven-plugin Teamscale Maven Plugin Maven Plugin for Teamscale @@ -21,7 +20,7 @@ The Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt + https://www.apache.org/licenses/LICENSE-2.0.txt @@ -61,15 +60,18 @@ 34.0.0 2.1.0 true - 1.8 - 1.8 - org.junit.jupiter - junit-jupiter-engine - 5.11.4 + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test-junit + ${kotlin.version} test @@ -77,6 +79,7 @@ teamscale-jacoco-agent ${teamscale.agent.version} + org.apache.maven maven-plugin-api @@ -95,6 +98,7 @@ 3.9.9 provided + org.eclipse.jgit org.eclipse.jgit @@ -111,11 +115,6 @@ ${teamscale.agent.version} runtime - - org.jetbrains.kotlin - kotlin-stdlib - 2.1.0 - @@ -132,6 +131,35 @@ + + org.jetbrains.kotlin + kotlin-maven-plugin + 2.1.0 + + + compile + + compile + + + + src/main/kotlin + + + + + test-compile + + test-compile + + + + src/test/kotlin + + + + + org.apache.maven.plugins maven-plugin-plugin @@ -145,11 +173,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - 3.5.2 - org.apache.maven.plugins maven-source-plugin @@ -163,40 +186,10 @@ - - - - - - - - - - - - - - org.jetbrains.kotlin - kotlin-maven-plugin - 2.1.0 - - - compile - process-sources - - compile - - - - src/main/kotlin - src/main/java - target/generated-sources/annotations - target/generated-sources/plugin - - - - + org.apache.maven.plugins + maven-surefire-plugin + 3.5.2 diff --git a/teamscale-maven-plugin/src/main/kotlin/com/teamscale/maven/tia/TiaMojoBase.kt b/teamscale-maven-plugin/src/main/kotlin/com/teamscale/maven/tia/TiaMojoBase.kt index 23c5c4847..16cae4ca4 100644 --- a/teamscale-maven-plugin/src/main/kotlin/com/teamscale/maven/tia/TiaMojoBase.kt +++ b/teamscale-maven-plugin/src/main/kotlin/com/teamscale/maven/tia/TiaMojoBase.kt @@ -268,13 +268,10 @@ abstract class TiaMojoBase : TeamscaleMojoBase() { configurationDom: Xpp3Dom, xmlConfigurationName: String ) { - val engines = configurationDom.getChild(xmlConfigurationName) - if (engines != null) { + configurationDom.getChild(xmlConfigurationName)?.let { throw MojoFailureException( "You configured JUnit 5 engines in the $testPluginArtifact plugin via the $xmlConfigurationName configuration parameter. This is currently not supported when performing Test Impact analysis. Please add the $xmlConfigurationName via the ${ - getPropertyName( - xmlConfigurationName - ) + getPropertyName(xmlConfigurationName) } property." ) } diff --git a/teamscale-maven-plugin/src/main/kotlin/com/teamscale/maven/upload/CoverageUploadMojo.kt b/teamscale-maven-plugin/src/main/kotlin/com/teamscale/maven/upload/CoverageUploadMojo.kt index 2f00be5d9..78cc7f553 100644 --- a/teamscale-maven-plugin/src/main/kotlin/com/teamscale/maven/upload/CoverageUploadMojo.kt +++ b/teamscale-maven-plugin/src/main/kotlin/com/teamscale/maven/upload/CoverageUploadMojo.kt @@ -190,7 +190,7 @@ class CoverageUploadMojo : TeamscaleMojoBase() { jacocoDirectory: String, reportOutputFiles: MutableList ) { - val defaultOutputDirectory = Paths.get(project.reporting.outputDirectory) + val defaultOutputDirectory = Paths.get(project.model.reporting.outputDirectory) // If a Dom is null it means the execution goal uses default parameters which work correctly val reportConfigurationDom = getJacocoGoalExecutionConfiguration(project, reportGoal) if (!validateReportFormat(reportConfigurationDom)) { diff --git a/teamscale-maven-plugin/src/test/java/com/teamscale/maven/tia/ArgLineTest.java b/teamscale-maven-plugin/src/test/java/com/teamscale/maven/tia/ArgLineTest.java deleted file mode 100644 index fbb54dbc3..000000000 --- a/teamscale-maven-plugin/src/test/java/com/teamscale/maven/tia/ArgLineTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.teamscale.maven.tia; - -import org.junit.jupiter.api.Test; - -import java.nio.file.Paths; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -class ArgLineTest { - - @Test - public void isIdempotent() { - ArgLine argLine = new ArgLine(null, "info", Paths.get("agent.jar"), Paths.get("agent.properties"), - Paths.get("agent.log")); - String firstArgLine = argLine.prependTo(""); - String secondArgLine = argLine.prependTo(ArgLine.removePreviousTiaAgent(firstArgLine)); - - assertEquals(firstArgLine, secondArgLine); - } - - @Test - public void testNullOriginalArgLine() { - ArgLine argLine = new ArgLine(null, "info", Paths.get("agent.jar"), Paths.get("agent.properties"), - Paths.get("agent.log")); - String newArgLine = argLine.prependTo(null); - - assertTrue(newArgLine.startsWith("-Dteamscale.markstart")); - assertTrue(newArgLine.endsWith("-Dteamscale.markend")); - } - - @Test - public void preservesUnrelatedAgents() { - String argLine = "-javaagent:someother.jar"; - String newArgLine = ArgLine.removePreviousTiaAgent(argLine); - - assertEquals(argLine, newArgLine); - } - -} \ No newline at end of file diff --git a/teamscale-maven-plugin/src/test/kotlin/com/teamscale/maven/tia/ArgLineTest.kt b/teamscale-maven-plugin/src/test/kotlin/com/teamscale/maven/tia/ArgLineTest.kt new file mode 100644 index 000000000..f57f3db95 --- /dev/null +++ b/teamscale-maven-plugin/src/test/kotlin/com/teamscale/maven/tia/ArgLineTest.kt @@ -0,0 +1,41 @@ +package com.teamscale.maven.tia + +import com.teamscale.maven.tia.ArgLine.Companion.removePreviousTiaAgent +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Test +import java.nio.file.Paths + +internal class ArgLineTest { + @Test + fun isIdempotent() { + val argLine = ArgLine( + null, "info", Paths.get("agent.jar"), Paths.get("agent.properties"), + Paths.get("agent.log") + ) + val firstArgLine = argLine.prependTo("") + val secondArgLine = argLine.prependTo(removePreviousTiaAgent(firstArgLine)) + + assertEquals(firstArgLine, secondArgLine) + } + + @Test + fun testNullOriginalArgLine() { + val argLine = ArgLine( + null, "info", Paths.get("agent.jar"), Paths.get("agent.properties"), + Paths.get("agent.log") + ) + val newArgLine = argLine.prependTo(null) + + assertTrue(newArgLine.startsWith("-Dteamscale.markstart")) + assertTrue(newArgLine.endsWith("-Dteamscale.markend")) + } + + @Test + fun preservesUnrelatedAgents() { + val argLine = "-javaagent:someother.jar" + val newArgLine = removePreviousTiaAgent(argLine) + + assertEquals(argLine, newArgLine) + } +} \ No newline at end of file