Skip to content

Commit

Permalink
openrewrite#936 separate tests of src/main/java and src/test/java int…
Browse files Browse the repository at this point in the history
…o two independent testcases
  • Loading branch information
reisners committed Jan 28, 2025
1 parent b09a186 commit 42d26c2
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/test/java/org/openrewrite/maven/KotlinIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,23 @@
@MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:run")
class KotlinIT {
@MavenTest
void basic_kotlin_project(MavenExecutionResult result) {
void kotlin_in_src_main_java(MavenExecutionResult result) {
assertThat(result)
.isSuccessful()
.out()
.debug()
.anySatisfy(line -> assertThat(line).contains("Scanned 1 kotlin source files in main scope."))
.anySatisfy(line -> assertThat(line).contains("org.openrewrite.kotlin.format.AutoFormat"));
}

@MavenTest
void kotlin_in_src_main_test(MavenExecutionResult result) {
assertThat(result)
.isSuccessful()
.out()
.debug()
.anySatisfy(line -> assertThat(line).contains("Scanned 1 kotlin source files in test scope."))
.anySatisfy(line -> assertThat(line).contains("org.openrewrite.kotlin.format.AutoFormat"));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.openrewrite.maven</groupId>
<artifactId>basic_kotlin_project</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>KotlinIT#basic_kotlin_project</name>

<properties>
<kotlin.version>1.9.10</kotlin.version>
<jdk.version>17</jdk.version>
<java.version>${jdk.version}</java.version>
<maven.compiler.source>${jdk.version}</maven.compiler.source>
<maven.compiler.target>${jdk.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.kotlin.format.AutoFormat</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-all</artifactId>
<version>1.3.4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>

<repositories>
<repository>
<id>mavenCentral</id>
<url>https://repo1.maven.org/maven2/</url>
</repository>
</repositories>
</project>

0 comments on commit 42d26c2

Please sign in to comment.