Class RemoveDependencyMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugins.dependency.AbstractDependencyMojo
-
- org.apache.maven.plugins.dependency.RemoveDependencyMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="remove", requiresProject=true, threadSafe=true) public class RemoveDependencyMojo extends AbstractDependencyMojoRemoves a dependency from the project'spom.xml. Supports removing from<dependencies>or<dependencyManagement>.Matching uses groupId, artifactId, type, and classifier for precision. If the dependency exists in Maven's resolved model but uses property references in the raw POM, a clear error directs the user to edit manually.
When removing a managed dependency from a parent POM, warns if child modules reference it without an explicit version.- Since:
- 3.11.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringclassifierDependency classifier for precise matching (e.g.,sources,javadoc,tests).private java.lang.StringgavDependency coordinates:groupId:artifactId[:version]orgroupId:artifactId[:extension[:classifier]]:version.private booleanmanagedWhentrue, remove from<dependencyManagement>instead of<dependencies>.private java.lang.StringprofileTarget a specific Maven profile by its<id>.private java.lang.StringtypeDependency type for precise matching (e.g.,pom,war,test-jar).-
Fields inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
session
-
-
Constructor Summary
Constructors Constructor Description RemoveDependencyMojo(org.apache.maven.execution.MavenSession session, org.sonatype.plexus.build.incremental.BuildContext buildContext, org.apache.maven.project.MavenProject project)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckChildModuleDependencies(org.apache.maven.project.MavenProject parentProject, java.lang.String depGroupId, java.lang.String depArtifactId)private eu.maveniverse.domtrip.maven.PomEditor.DependenciesdependenciesFor(eu.maveniverse.domtrip.maven.PomEditor editor, java.io.File pomFile)protected voiddoExecute()private static eu.maveniverse.domtrip.maven.PomEditorloadPomEditor(java.io.File pomFile)private DependencyEntryresolveCoordinates()private static java.io.FileresolveModulePom(java.io.File parentBasedir, java.lang.String moduleName)private static voidsavePomEditor(eu.maveniverse.domtrip.maven.PomEditor editor, java.io.File pomFile)-
Methods inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
execute, existsInResolvedModel, getProject, isSilent, isSkip, setSilent, setSkip
-
-
-
-
Field Detail
-
gav
@Parameter(property="gav") private java.lang.String gav
Dependency coordinates:groupId:artifactId[:version]orgroupId:artifactId[:extension[:classifier]]:version. Only groupId and artifactId are required. Type and classifier, if provided, are used for precise matching when multiple dependency variants exist (e.g., jar vs test-jar).- Since:
- 3.11.0
-
managed
@Parameter(property="managed", defaultValue="false") private boolean managedWhentrue, remove from<dependencyManagement>instead of<dependencies>.- Since:
- 3.11.0
-
type
@Parameter(property="type") private java.lang.String type
Dependency type for precise matching (e.g.,pom,war,test-jar). When not specified, defaults to"jar".- Since:
- 3.11.0
-
classifier
@Parameter(property="classifier") private java.lang.String classifier
Dependency classifier for precise matching (e.g.,sources,javadoc,tests).- Since:
- 3.11.0
-
profile
@Parameter(property="profile") private java.lang.String profile
Target a specific Maven profile by its<id>. When set, the dependency is removed from the profile's<dependencies>or<dependencyManagement>section. The profile must already exist in the POM.- Since:
- 3.11.0
-
-
Method Detail
-
doExecute
protected void doExecute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Specified by:
doExecutein classAbstractDependencyMojo- Throws:
org.apache.maven.plugin.MojoExecutionException-MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException-MojoFailureException
-
dependenciesFor
private eu.maveniverse.domtrip.maven.PomEditor.Dependencies dependenciesFor(eu.maveniverse.domtrip.maven.PomEditor editor, java.io.File pomFile) throws org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoFailureException
-
loadPomEditor
private static eu.maveniverse.domtrip.maven.PomEditor loadPomEditor(java.io.File pomFile) throws java.io.IOException- Throws:
java.io.IOException
-
savePomEditor
private static void savePomEditor(eu.maveniverse.domtrip.maven.PomEditor editor, java.io.File pomFile) throws java.io.IOException- Throws:
java.io.IOException
-
resolveCoordinates
private DependencyEntry resolveCoordinates() throws org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoFailureException
-
checkChildModuleDependencies
private void checkChildModuleDependencies(org.apache.maven.project.MavenProject parentProject, java.lang.String depGroupId, java.lang.String depArtifactId) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
resolveModulePom
private static java.io.File resolveModulePom(java.io.File parentBasedir, java.lang.String moduleName)
-
-