elharo commented on code in PR #413:
URL: https://github.com/apache/maven-archiver/pull/413#discussion_r4144268667


##########
src/main/java/org/apache/maven/shared/archiver/BuildHelper.java:
##########
@@ -109,12 +116,94 @@ public static String getPluginParameter(Model model, 
Plugin plugin, String param
         return value;
     }
 
+    /**
+     * Determines whether a Maven module will be deployed to a remote 
repository.
+     * <p>
+     * This method analyses the model's plugin configuration to detect if 
deployment will be skipped,
+     * taking into account the three known deployment mechanisms:
+     * <ol>
+     * <li>{@code central-publishing-maven-plugin} — the new Sonatype Central 
Portal publisher; when

Review Comment:
   Break up run-on sentences.



##########
src/main/java/org/apache/maven/shared/archiver/BuildHelper.java:
##########
@@ -109,12 +116,94 @@ public static String getPluginParameter(Model model, 
Plugin plugin, String param
         return value;
     }
 
+    /**
+     * Determines whether a Maven module will be deployed to a remote 
repository.
+     * <p>
+     * This method analyses the model's plugin configuration to detect if 
deployment will be skipped,
+     * taking into account the three known deployment mechanisms:
+     * <ol>
+     * <li>{@code central-publishing-maven-plugin} — the new Sonatype Central 
Portal publisher; when
+     *     present it replaces {@code maven-deploy-plugin}. The module is 
considered deployable if the
+     *     plugin has at least one execution of the {@code publish} goal that 
is not skipped (via the
+     *     {@code skipPublishing} parameter or property).</li>
+     * <li>{@code nexus-staging-maven-plugin} — the legacy Sonatype OSS 
publisher; when present it
+     *     replaces standard deploy. The module is considered deployable if it 
has at least one execution
+     *     of the {@code deploy} goal that is not skipped (via the {@code 
skipNexusStagingDeployMojo}
+     *     parameter or property).</li>
+     * <li>{@code maven-deploy-plugin} — the standard deploy plugin. The 
module is deployable if it has
+     *     at least one execution of the {@code deploy} goal that is not 
skipped (via the {@code skip}
+     *     parameter or the {@code maven.deploy.skip} property).</li>
+     * </ol>
+     * The extension plugins are checked first. If neither is present, the 
standard deploy plugin is
+     * checked. A module with none of these plugins configured is considered 
deployable by default.
+     *
+     * @param model the effective (fully-resolved) project model, not null
+     * @return {@code true} if the module will be deployed to a remote 
repository, {@code false} otherwise
+     * @since 4.0.0-beta-6

Review Comment:
   I tend to leave beta out of since tags. Maybe just since 4.0.0



##########
src/main/java/org/apache/maven/shared/archiver/BuildHelper.java:
##########
@@ -109,12 +116,94 @@ public static String getPluginParameter(Model model, 
Plugin plugin, String param
         return value;
     }
 
+    /**
+     * Determines whether a Maven module will be deployed to a remote 
repository.
+     * <p>
+     * This method analyses the model's plugin configuration to detect if 
deployment will be skipped,
+     * taking into account the three known deployment mechanisms:
+     * <ol>
+     * <li>{@code central-publishing-maven-plugin} — the new Sonatype Central 
Portal publisher; when
+     *     present it replaces {@code maven-deploy-plugin}. The module is 
considered deployable if the
+     *     plugin has at least one execution of the {@code publish} goal that 
is not skipped (via the
+     *     {@code skipPublishing} parameter or property).</li>
+     * <li>{@code nexus-staging-maven-plugin} — the legacy Sonatype OSS 
publisher; when present it
+     *     replaces standard deploy. The module is considered deployable if it 
has at least one execution
+     *     of the {@code deploy} goal that is not skipped (via the {@code 
skipNexusStagingDeployMojo}
+     *     parameter or property).</li>
+     * <li>{@code maven-deploy-plugin} — the standard deploy plugin. The 
module is deployable if it has
+     *     at least one execution of the {@code deploy} goal that is not 
skipped (via the {@code skip}
+     *     parameter or the {@code maven.deploy.skip} property).</li>
+     * </ol>
+     * The extension plugins are checked first. If neither is present, the 
standard deploy plugin is
+     * checked. A module with none of these plugins configured is considered 
deployable by default.
+     *
+     * @param model the effective (fully-resolved) project model, not null
+     * @return {@code true} if the module will be deployed to a remote 
repository, {@code false} otherwise
+     * @since 4.0.0-beta-6
+     */
+    public static boolean isDeployable(Model model) {
+        Plugin centralPublishing = getPlugin(model, CENTRAL_PUBLISHING_PLUGIN);
+        if (centralPublishing != null) {

Review Comment:
   Can more than one of these plugins be present, with one deployable and one 
not?



##########
src/test/java/org/apache/maven/shared/archiver/BuildHelperTest.java:
##########
@@ -0,0 +1,302 @@
+/*
+ * 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.shared.archiver;
+
+import java.io.StringReader;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.api.model.Build;
+import org.apache.maven.api.model.Model;
+import org.apache.maven.api.model.Plugin;
+import org.apache.maven.api.model.PluginExecution;
+import org.apache.maven.api.xml.XmlNode;
+import org.apache.maven.api.xml.XmlService;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class BuildHelperTest {
+
+    // 
-------------------------------------------------------------------------
+    // isDeployable: no deploy-related plugins
+    // 
-------------------------------------------------------------------------
+
+    @Test
+    void isDeployableWithNoPluginsReturnsTrue() {
+        Model model = Model.newBuilder().build();
+        assertThat(BuildHelper.isDeployable(model)).isTrue();
+    }
+
+    // 
-------------------------------------------------------------------------
+    // isDeployable: maven-deploy-plugin
+    // 
-------------------------------------------------------------------------
+
+    @Test
+    void isDeployableWithDeployPluginNoExecutionNotSkippedReturnsTrue() {
+        Plugin deployPlugin = Plugin.newBuilder()
+                .groupId("org.apache.maven.plugins")
+                .artifactId("maven-deploy-plugin")
+                .build();
+        Model model = modelWithPlugin(deployPlugin);
+        assertThat(BuildHelper.isDeployable(model)).isTrue();

Review Comment:
   This is harder to read than a simple assertTrue



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