-
Notifications
You must be signed in to change notification settings - Fork 83
Make rewrite-maven-plugin search for Kotlin source files in src/*/java if src/*/kotlin does not exist #937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MBoegers
merged 12 commits into
openrewrite:main
from
reisners:stefanr_fix_kotlin_source_paths
Jan 28, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a20ae6b
add test case
reisners bc70ce3
minor cleanup
reisners b2fdf79
intentionally mess up formatting
reisners 9e5e0db
#936 in case of missing src/*/kotlin fall back to scanning for Kotlin…
reisners 2b96e35
Merge branch 'main' into stefanr_fix_kotlin_source_paths
reisners 15d5c58
#936 rename variable in processTestSources more aptly to kotlinTestSo…
reisners 595b27a
#936 refactor listKotlinSources()
reisners 04d2104
#936 also verify that Kotlin source files are found unter src/test/java
reisners b09a186
#936 fix debug log message
reisners 42d26c2
#936 separate tests of src/main/java and src/test/java into two indep…
reisners 3d5c9e5
#936 removed @NotNull annotation and annotated package as @NullMarked
reisners 3295c1a
polishing with best practices subset
MBoegers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.