-
Notifications
You must be signed in to change notification settings - Fork 363
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
Modify default behaviour of MavenVisitor::isPluginTag() to search everywhere, not just build #4156
Conversation
rewrite-maven/src/main/java/org/openrewrite/maven/MavenVisitor.java
Outdated
Show resolved
Hide resolved
Thanks for getting this started @dawngerpony ! Reminds me of this change we did a while back I should probably have been consistent at the time to roll that out for plugins as well; thanks for picking that up now. For dependencies we ended up with updating dependencies wherever they are found by default; with a new option only to disable that behaviour. The motivation being that it's less surprising to users: then want to change a dependency; not have to remember to also change managed dependencies, or plugin dependencies, or profile managed plugin dependencies, and so on... I'm thinking we can do the same here: by default update all locations where a plugin might be found, and maybe even leave out the option to limit that until we get specific complaints. To that end I'm wondering if we can simplify the implementation here by updating this specific matcher to use for instance
What would be your thoughts to such an approach? I know you've been careful not to make any breaking changes, but in this case I think the gain in functionality is tolerable. |
If you're on board then I'm on board! Would you even recommend that we literally just update |
That's what I was eyeing this afternoon indeed, as I had trouble thinking of use cases where folks would want to to do one but not the other, without resorting to a custom recipe. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! Good to be consistent, with less code to boot.
@@ -33,14 +33,13 @@ | |||
import static org.openrewrite.internal.StringUtils.matchesGlob; | |||
|
|||
public class MavenVisitor<P> extends XmlVisitor<P> { | |||
|
|||
static final XPathMatcher DEPENDENCY_MATCHER = new XPathMatcher("/project/dependencies/dependency"); | |||
static final XPathMatcher PLUGIN_DEPENDENCY_MATCHER = new XPathMatcher("/project/*/plugins/plugin/dependencies/dependency"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not strictly related to this PR, but should we possibly also here match plugin dependencies in profiles?
static final XPathMatcher PLUGIN_DEPENDENCY_MATCHER = new XPathMatcher("/project/*/plugins/plugin/dependencies/dependency"); | |
static final XPathMatcher PLUGIN_DEPENDENCY_MATCHER = new XPathMatcher("//plugins/plugin/dependencies/dependency"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: The corresponding isPluginDependencyTag()
method is being used by the UpgradeDependencyVersion
recipe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Followed up with cfed3dc just now.
What's changed?
MavenVisitor::isPluginTag()
to search everywhere, not just in the<build><plugins>
section. Recipes that use this method to modify plugin definitions will now find that theirpluginManagement
sections are being updated too.What's your motivation?
We need this behaviour in our own recipes and we'd like to push it down the stack, because I thought others would find it useful too.
Anything in particular you'd like reviewers to focus on?
Not any more since the review.
Anyone you would like to review specifically?
@timtebeek perhaps?
Have you considered any alternatives or workarounds?
I don't see any reasonable alternatives, other than adding the matching logic to every recipe which needs it.
Any additional context
None.
Checklist