Skip to content

Openwrite ignores profile dependent modules in maven multi module projects #621

Description

@chhex

What version of OpenRewrite are you using?

rewrite-bom : 8.4.2
rerwrite-java-17

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>5.4.2</version>
  <configuration>
    ... 
  </configuration>
</plugin>
 .\mvnw.cmd -version
Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
Maven home: C:\Users\che\.m2\wrapper\dists\apache-maven-3.9.1-bin\320285b4\apache-maven-3.9.1
Java version: 17.0.8, vendor: Microsoft, runtime: C:\data\java\jdk-17.0.8+7
Default locale: de_CH, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

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

See https://github.com/chhex/demo/tree/main

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

Openrewrite applies the recipes on all the modules instead of the modules, which are actually active according to the pom, see https://github.com/chhex/demo/blob/main/pom.xml

The misbehavior can easily be reproduced by running:

 .\mvnw.cmd rewrite:run  # Correctly runs the recipes on all  modules

.\mvnw.cmd rewrite:run -P!InclB # Incorrectly runs the recipes on all modules

The good news is that you can run the open rewrite recipes selectively on a per module basis :

 .\mvnw.cmd rewrite:run  # Correctly runs the recipes on all  modules

.\mvnw.cmd rewrite:run -P!InclB # Incorrectly runs the recipes on all modules

.\mvnw.cmd rewrite:run  -pl :A #  Runs correctly only the Module A 

The later serving as workaround for our usage scenario. Naturally only a workaround, because you cannot delegate the selection of modules you want to run recipes on to the maven pom.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions