Rewrite java packages and groupid/artifact names of super pom project

201 Views Asked by At

I'm trying to use openrewrite to refactor one of my projects which is a hierachical maven project (super POM with submodules). Basically I want to replace 1 package name with a new package name (fe. org.myproject to com.myproject) and refactor also the artifact names.

I can already replace the package name if I use it inside a specific module but when I try to add the maven rewrite plugin on the super pom it doesn't get executed (it even doesn't find the plugin).

Does anyone have a sample how to use openrewrite on a super POM file ?

1

There are 1 best solutions below

0
On

olus, sorry it took a while to spot your question, we're a little more active on Slack, but will be monitoring here as well.

We've heard some people report issues when running with multi-module projects before, although in the past I've gotten around that by using a Maven profile on the parent pom.xml. Perhaps a similar approach could work for you as well.

<profile>
  <id>openrewrite</id>
  <build>
    <plugins>
      <plugin>
        <groupId>org.openrewrite.maven</groupId>
        <artifactId>rewrite-maven-plugin</artifactId>
        <version>4.38.2</version>
        <configuration>
          <activeRecipes>
            <recipe>org.openrewrite.java.cleanup.Cleanup</recipe>
          </activeRecipes>
          <failOnDryRunResults>true</failOnDryRunResults>
        </configuration>
      </plugin>
    </plugins>
  </build>
</profile>

Either way I've logged an issue to improve the documentation, as you should not have to ask here to find an answer. Hope this helps!