Programmatically Exclude Specific Maven Dependencies
programmatically search for a given dependency within a Maven pom.xml file and automatically apply an
Requirements:
Search pom.xml for a specific dependency by groupId and artifactId
Identify the direct parent dependency that brings it in transitively
Insert an
Preserve formatting and comments in pom.xml as much as possible
Use Case Example: We want to exclude commons-collections:commons-collections from a transitive dependency like org.springframework:spring-core. The tool should locate spring-core and inject the following:
xml
Copy
Edit