slawekjaranowski commented on code in PR #1599:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/1599#discussion_r3229340980


##########
src/main/java/org/apache/maven/plugins/dependency/AddDependencyMojo.java:
##########
@@ -0,0 +1,803 @@
+/*
+ * 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.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+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.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.sonatype.plexus.build.incremental.BuildContext;
+
+/**
+ * Adds a dependency to the project's {@code pom.xml}.
+ * Supports adding to {@code <dependencies>} or {@code <dependencyManagement>},
+ * with version inference from managed dependencies.
+ *
+ * <p>If the dependency already exists, the goal fails with a descriptive error
+ * directing the user to remove it first.</p>
+ *
+ * <p>The goal uses formatting-preserving DOM manipulation to maintain the 
POM's
+ * existing structure (comments, indentation, encoding). Duplicate detection 
uses
+ * type and classifier-aware matching, and cross-references Maven's resolved 
model
+ * to catch dependencies declared via property references.</p>
+ *
+ * <p>Scope values are validated against Maven's known scopes:
+ * {@code compile}, {@code provided}, {@code runtime}, {@code test}, {@code 
system}, {@code import}.</p>
+ *
+ * @since 3.11.0
+ */
+@Mojo(name = "add", requiresProject = true, threadSafe = true)
+public class AddDependencyMojo extends AbstractDependencyMojo {
+
+    /**
+     * Dependency coordinates: {@code groupId:artifactId[:version]}
+     * or {@code groupId:artifactId[:extension[:classifier]]:version}.
+     * Scope, type, classifier, and optional can be overridden via separate 
parameters.
+     */
+    @Parameter(property = "gav")

Review Comment:
   and rest of `@Parameter`



-- 
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]

Reply via email to