-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make rewrite-maven-plugin search for Kotlin source files in src/*/jav…
…a if src/*/kotlin does not exist (#937) * add test case which fails initially because 0 kotlin source files will be found in the non-existent src/main/kotlin * minor cleanup * intentionally mess up formatting * #936 in case of missing src/*/kotlin fall back to scanning for Kotlin sources in src/*/java instead * #936 rename variable in processTestSources more aptly to kotlinTestSourceDir (was kotlinSourceDir) * #936 refactor listKotlinSources() * #936 also verify that Kotlin source files are found unter src/test/java * #936 fix debug log message * #936 separate tests of src/main/java and src/test/java into two independent testcases * #936 removed @NotNull annotation and annotated package as @NullMarked * polishing with best practices subset --------- Co-authored-by: Merlin Bögershausen <[email protected]>
- Loading branch information
Showing
8 changed files
with
300 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2020 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.openrewrite.maven; | ||
|
||
import com.soebes.itf.jupiter.extension.*; | ||
import com.soebes.itf.jupiter.maven.MavenExecutionResult; | ||
import org.junit.jupiter.api.condition.DisabledOnOs; | ||
import org.junit.jupiter.api.condition.OS; | ||
|
||
import static com.soebes.itf.extension.assertj.MavenITAssertions.assertThat; | ||
|
||
@MavenJupiterExtension | ||
@MavenOption(MavenCLIOptions.NO_TRANSFER_PROGRESS) | ||
@MavenOption(MavenCLIExtra.MUTE_PLUGIN_VALIDATION_WARNING) | ||
@MavenOption(MavenCLIOptions.VERBOSE) | ||
@DisabledOnOs(OS.WINDOWS) | ||
@MavenGoal("install") | ||
@MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:run") | ||
class KotlinIT { | ||
@MavenTest | ||
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")); | ||
} | ||
|
||
} |
111 changes: 111 additions & 0 deletions
111
src/test/resources-its/org/openrewrite/maven/KotlinIT/kotlin_in_src_main_java/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
5 changes: 5 additions & 0 deletions
5
...ts/org/openrewrite/maven/KotlinIT/kotlin_in_src_main_java/src/main/java/sample/MyClass.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package sample | ||
|
||
class MyClass { | ||
|
||
} |
111 changes: 111 additions & 0 deletions
111
src/test/resources-its/org/openrewrite/maven/KotlinIT/kotlin_in_src_main_test/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
4 changes: 4 additions & 0 deletions
4
...its/org/openrewrite/maven/KotlinIT/kotlin_in_src_main_test/src/test/java/sample/MyTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package sample | ||
|
||
class MyTest { | ||
} |
3 changes: 2 additions & 1 deletion
3
...openrewrite/maven/RewriteDryRunIT/recipe_order/src/main/java/sample/EmptyBlockSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters