-
Notifications
You must be signed in to change notification settings - Fork 354
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
Add Dependecies only in specific modules #4453
base: main
Are you sure you want to change the base?
Add Dependecies only in specific modules #4453
Conversation
…in specific modules
Hmm; wouldn't this be better served with a precondition? We've introduced that concept to prevent us from having to add similar options to multiple recipes, for the long term maintainability of the project. In general we want recipes to be able to run with the same configuration across multiple projects. An option like |
Hi @timtebeek , the condition rewrite/rewrite-maven/src/main/java/org/openrewrite/maven/AddDependency.java Lines 238 to 240 in b64e1ed
I tried to use it with a precondition at first. However, because I can't specify onlyIfUsing and my parent POM actually is defined in my current repository, the dependency never gets created. We thought, this would be the simplest increment without changing existing behavior. Of course, we're open for other suggestions ^^ For my own use-case, I've created my own recipe that calls the underlying AddDependencyVisitor with a precondition. At least, I could contribute my search recipe for selecting a module. Then @marcel-gepardec only has to change the condition in question. |
I'm not sure fully see the use case here, but that could also be because I have limited time to dive into the specifics. I do still feel that adding What's the practical use here at all of adding a dependency to a specific module without any And don't get me wrong: I appreciate all the contributions, even if I don't always find time to review them within a week. In this case I'm mostly wondering if it even is a case we should generalize, and then maintain those options, or whether a specific in house recipe could be better. |
Hi, I already understood your doubts about
For these use-cases, You'd have to call AddDependencyVisitor manually in a java recipe. My proposition is to:
Again, currently I can't add a dependency, when:
|
A new option to specify a module name in the existing AddDependency recipe has been added. There the dependency will only be added in the specific module.
What's changed?
Added the option "specificModuleName" to the AddDependency Recipe. If "specificModuleName" is added, the dependency will only be added in the specific module and not in the root POM.
Example:
Before:
After:
What's your motivation?
A work colleague discovered that the option "onlyIfUsing" is not very consistent and will miss some types. So the solution was to add an option where you can specifically mention the module name in which the dependency should be added.