slawekjaranowski commented on code in PR #1599: URL: https://github.com/apache/maven-dependency-plugin/pull/1599#discussion_r3229355317
########## src/main/java/org/apache/maven/plugins/dependency/RemoveDependencyMojo.java: ########## @@ -0,0 +1,321 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.dependency; + +import javax.inject.Inject; + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.io.Reader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.Locale; + +import eu.maveniverse.domtrip.Document; +import eu.maveniverse.domtrip.Element; +import eu.maveniverse.domtrip.maven.Coordinates; +import eu.maveniverse.domtrip.maven.PomEditor; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.dependency.pom.DependencyEntry; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.util.xml.XmlStreamReader; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; +import org.sonatype.plexus.build.incremental.BuildContext; + +/** + * Removes a dependency from the project's {@code pom.xml}. + * Supports removing from {@code <dependencies>} or {@code <dependencyManagement>}. + * + * <p>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.</p> + * When removing a managed dependency from a parent POM, warns if child modules + * reference it without an explicit version. + * + * @since 3.11.0 + */ +@Mojo(name = "remove", requiresProject = true, threadSafe = true) +public class RemoveDependencyMojo extends AbstractDependencyMojo { + + /** + * Dependency coordinates: {@code groupId:artifactId[:version]} + * or {@code groupId: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). Review Comment: It will be generate in one line in documentation - to check how it will look. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
