Skip to content
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

Kotlin source files under src/main/java should be detected #936

Open
reisners opened this issue Jan 23, 2025 · 1 comment
Open

Kotlin source files under src/main/java should be detected #936

reisners opened this issue Jan 23, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@reisners
Copy link
Contributor

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v8.43.3
  • Maven/Gradle plugin v6.0.3

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a single module project.

<plugin>
  <groupId>org.openrewrite.maven</groupId>
  <artifactId>rewrite-maven-plugin</artifactId>
  <version>1.2.3</version>
  <configuration>
    ... 
  </configuration>
</plugin>

What is the smallest, simplest way to reproduce the problem?

Given Kotlin source filesrc/main/java/sample/MyClass.kt with content below,

 package sample
  class MyClass {
     }

and the kotlin-maven-plugin configured as follows,

                        <configuration>
                            <sourceDirs>
                                <sourceDir>${project.basedir}/src/main/java</sourceDir>
                            </sourceDirs>
                        </configuration>

invoking the Autoformat recipe using this command line

mvn -U org.openrewrite.maven:rewrite-maven-plugin:6.0.3:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-all:1.3.4 -Drewrite.activeRecipes=org.openrewrite.kotlin.format.AutoFormat

What did you expect to see?

The Kotlint source file src/main/java/sample/MyClass.kt should have been detected and reformatted into

package sample
class MyClass {
}

What did you see instead?

The Kotlin source file at src/main/java/sample/MyClass.kt was not detected and therefore not reformatted.

What is the full stack trace of any errors you encountered?

There was no error.

Are you interested in contributing a fix to OpenRewrite?

Yes, I am preparing a PR with a fix.

@reisners reisners added the bug Something isn't working label Jan 23, 2025
@timtebeek timtebeek moved this to In Progress in OpenRewrite Jan 24, 2025
reisners added a commit to reisners/rewrite-maven-plugin that referenced this issue Jan 25, 2025
reisners added a commit to reisners/rewrite-maven-plugin that referenced this issue Jan 28, 2025
reisners added a commit to reisners/rewrite-maven-plugin that referenced this issue Jan 28, 2025
reisners added a commit to reisners/rewrite-maven-plugin that referenced this issue Jan 28, 2025
reisners added a commit to reisners/rewrite-maven-plugin that referenced this issue Jan 28, 2025
reisners added a commit to reisners/rewrite-maven-plugin that referenced this issue Jan 28, 2025
reisners added a commit to reisners/rewrite-maven-plugin that referenced this issue Jan 28, 2025
MBoegers added a commit that referenced this issue Jan 28, 2025
…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]>
@MBoegers
Copy link
Contributor

@reisners could you retest with your local build plugin and briefly report the result?
mvn install and updating the build using it should do the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: In Progress
Development

No branches or pull requests

2 participants