Skip to content

Latest commit

 

History

History
46 lines (40 loc) · 1.34 KB

File metadata and controls

46 lines (40 loc) · 1.34 KB

Flatten Kotlin recipe for OpenRewrite

The Kotlin coding conventions advise omitting the common root package:

In pure Kotlin projects, the recommended directory structure follows the package structure with the common root package omitted. For example, if all the code in the project is in the org.example.kotlin package and its subpackages, files with the org.example.kotlin package should be placed directly under the source root, and files in org.example.kotlin.network.socket should be in the network/socket subdirectory of the source root.

Usage

pom.xml
<build>
  <plugins>
    <plugin>
      <groupId>org.openrewrite.maven</groupId>
      <artifactId>rewrite-maven-plugin</artifactId>
      <version>6.8.0</version>
      <configuration>
        <activeRecipes>
          <recipe>com.yourorg.yourproject.Migrate</recipe>
        </activeRecipes>
      </configuration>
    </plugin>
  </plugins>
</build>
rewrite.yml
---
type: specs.openrewrite.org/v1beta/recipe
name: ch.frankel.MyMigration
recipeList:
  - ch.frankel.openrewrite.kotlin.FlattenStructure:
      rootPackage: com.acme
Warning

The plugin assumes you store your source files under src/main/kotlin.