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 AbstractDependencyMojo
Removes a dependency from the project's
pom.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
FieldsModifier and TypeFieldDescriptionprivate StringDependency classifier for precise matching (e.g.,sources,javadoc,tests).private StringDependency coordinates:groupId:artifactId[:version]orgroupId:artifactId[:extension[:classifier]]:version.private booleanWhentrue, remove from<dependencyManagement>instead of<dependencies>.private StringTarget a specific Maven profile by its<id>.private StringDependency type for precise matching (e.g.,pom,war,test-jar).Fields inherited from class AbstractDependencyMojo
sessionFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
ConstructorsConstructorDescriptionRemoveDependencyMojo(org.apache.maven.execution.MavenSession session, org.sonatype.plexus.build.incremental.BuildContext buildContext, org.apache.maven.project.MavenProject project) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckChildModuleDependencies(org.apache.maven.project.MavenProject parentProject, String depGroupId, String depArtifactId) private eu.maveniverse.domtrip.maven.PomEditor.DependenciesdependenciesFor(eu.maveniverse.domtrip.maven.PomEditor editor, File pomFile) protected voidprivate static eu.maveniverse.domtrip.maven.PomEditorloadPomEditor(File pomFile) private DependencyEntryprivate static FileresolveModulePom(File parentBasedir, String moduleName) private static voidsavePomEditor(eu.maveniverse.domtrip.maven.PomEditor editor, File pomFile) Methods inherited from class AbstractDependencyMojo
execute, existsInResolvedModel, getProject, isSilent, isSkip, setSilent, setSkipMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
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
Dependency type for precise matching (e.g.,pom,war,test-jar). When not specified, defaults to"jar".- Since:
- 3.11.0
-
classifier
Dependency classifier for precise matching (e.g.,sources,javadoc,tests).- Since:
- 3.11.0
-
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
-
-
Constructor Details
-
RemoveDependencyMojo
@Inject public RemoveDependencyMojo(org.apache.maven.execution.MavenSession session, org.sonatype.plexus.build.incremental.BuildContext buildContext, org.apache.maven.project.MavenProject project)
-
-
Method Details
-
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, File pomFile) throws org.apache.maven.plugin.MojoFailureException - Throws:
org.apache.maven.plugin.MojoFailureException
-
loadPomEditor
private static eu.maveniverse.domtrip.maven.PomEditor loadPomEditor(File pomFile) throws IOException - Throws:
IOException
-
savePomEditor
private static void savePomEditor(eu.maveniverse.domtrip.maven.PomEditor editor, File pomFile) throws IOException - Throws:
IOException
-
resolveCoordinates
- Throws:
org.apache.maven.plugin.MojoFailureException
-
checkChildModuleDependencies
-
resolveModulePom
-