-
Notifications
You must be signed in to change notification settings - Fork 82
Openwrite ignores profile dependent modules in maven multi module projects #621
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
Comments
Appreciate the reproduction sample @chhex ! Hadn't seen that pattern of adding modules to profiles before. As it's new to me I'll provide some context, and we can see where to take things from there. The way we discover source files is to ask the Maven session for available modules, as per rewrite-maven-plugin/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java Lines 129 to 141 in bcf7a65
As you can see there's also the -Drewrite.runPerSubmodule option that could be used, but I'm assuming that's not the code path triggered here.
The MavenSession class has two methods to get a list of projects: /**
* These projects have already been topologically sorted in the {@link org.apache.maven.Maven} component before
* being passed into the session. This is also the potentially constrained set of projects by using --projects
* on the command line.
*/
private List<MavenProject> projects;
/**
* The full set of projects before any potential constraining by --projects. Useful in the case where you want to
* build a smaller set of projects but perform other operations in the context of your reactor.
*/
private List<MavenProject> allProjects; We use I'm not immediately seeing a way to query for or filter on any Could you let us know if we should keep this issue open for you? I don't immediately see how we can support this case, so we'd likely have to rely either on you, or someone else to implement this feature. |
@timtebeek I appreciate your feedback. I also appreciate the great product your working on. The problem is not really a high priority for us, because of the workaround we have. It is at most somewhat irritating, since the Plugin doesn’t reflect the standard behavior of Maven. I would love the give it a look and a try, but need some time, since i have a day job. If you can leave it open for me a moment would be great! I inform you further along the line. If that’s ok with you, thanks a lot. |
Thanks for the kind words and offer to help if you find the time; I'll leave the issue open for now, and we can see where things stand in a month or so. And even if the issue were to get closed in the future as something not planned to be fixed in the short term, you're just as welcome to provide a fix PR if you find the time and solution to the above at a later date. :) |
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.
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:
The good news is that you can run the open rewrite recipes selectively on a per module basis :
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.
The text was updated successfully, but these errors were encountered: