Skip to content

Commit

Permalink
TS-38628 POM cleanup and kotlin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Avanatiker committed Jan 15, 2025
1 parent 5aa4400 commit 31f7877
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
93 changes: 43 additions & 50 deletions teamscale-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
c.f. https://maven.apache.org/docs/3.2.1/release-notes.html
-->
<version>${revision}</version>
<packaging>maven-plugin</packaging>

<name>Teamscale Maven Plugin</name>
<description>Maven Plugin for Teamscale</description>
Expand All @@ -21,7 +20,7 @@
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

Expand Down Expand Up @@ -61,22 +60,26 @@
<teamscale.agent.version>34.0.0</teamscale.agent.version>
<kotlin.version>2.1.0</kotlin.version>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.11.4</version>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.teamscale</groupId>
<artifactId>teamscale-jacoco-agent</artifactId>
<version>${teamscale.agent.version}</version>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
Expand All @@ -95,6 +98,7 @@
<version>3.9.9</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
Expand All @@ -111,11 +115,6 @@
<version>${teamscale.agent.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>

<build>
Expand All @@ -132,6 +131,35 @@
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>2.1.0</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/main/kotlin</source>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/test/kotlin</source>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
Expand All @@ -145,11 +173,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
Expand All @@ -163,40 +186,10 @@
</execution>
</executions>
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-javadoc-plugin</artifactId>-->
<!-- <version>3.11.2</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>attach-javadocs</id>-->
<!-- <goals>-->
<!-- <goal>jar</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>2.1.0</version>
<executions>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/main/kotlin</source>
<source>src/main/java</source>
<source>target/generated-sources/annotations</source>
<source>target/generated-sources/plugin</source>
</sourceDirs>
</configuration>
</execution>
</executions>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class CoverageUploadMojo : TeamscaleMojoBase() {
jacocoDirectory: String,
reportOutputFiles: MutableList<Path>
) {
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)) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit 31f7877

Please sign in to comment.