RemoveDependency
: how to delete multiple things with same groupId?
#4792
Replies: 2 comments 2 replies
-
Hi @svaningelgem ; I've quickly tried to replicate this issue with a unit test, but was not able to using this example: @Issue("https://github.com/openrewrite/rewrite/discussions/4792")
@Test
void removeTwoDependencies() {
rewriteRun(
spec -> spec.recipes(
new RemoveDependency("junit", "junit", null),
new RemoveDependency("com.google.guava", "guava", null)
),
pomXml(
"""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>29.0-jre</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
""",
"""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
</project>
"""
)
);
} Are you able to replicate this with a smaller sample perhaps? As an implementation detail: the dependency is removed by calling out to a visitor to remove that specific tag: If that tag can then not be found, perhaps because another recipe modified it in some way, then it will not be removed as it fails to match (different identity). |
Beta Was this translation helpful? Give feedback.
-
That might be possible because I'm changing the groupId from |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have this recipe:
However, when ran I only see one is processed (the first):
Why are the others not processed? (FYI: the other recipe also matches in that same pom file)
Or should I understand it as that the recipe is a set, with the key the class name?
=> that would make sense to remove duplicates from recipes -- but in this case it's not taking into account the parameters - which are different...
=> And if so: that would be a bug imho?
Oh, I also tried to extract them from the recipeList in their own recipe, and include that in the main list like this:
But that didn't work out either (also only security is removed)
Beta Was this translation helpful? Give feedback.
All reactions