You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2018/02/27 13:02:57 UTC

commons-release-plugin git commit: disabling plugin if not configured properly

Repository: commons-release-plugin
Updated Branches:
  refs/heads/master c176e464e -> 931dc5278


disabling plugin if not configured properly


Project: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/commit/931dc527
Tree: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/tree/931dc527
Diff: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/diff/931dc527

Branch: refs/heads/master
Commit: 931dc52788e8ae5db850068c64a2f3acfb0b2b03
Parents: c176e46
Author: Rob Tompkins <ch...@gmail.com>
Authored: Tue Feb 27 08:02:50 2018 -0500
Committer: Rob Tompkins <ch...@gmail.com>
Committed: Tue Feb 27 08:02:50 2018 -0500

----------------------------------------------------------------------
 pom.xml                                         |  2 +-
 .../CommonsDistributionDetachmentMojo.java      | 13 ++++++++++--
 .../mojos/CommonsDistributionStagingMojo.java   | 20 ++++++++++++-------
 .../mojos/CommonsSiteCompressionMojo.java       | 21 +++++++++++++++++---
 4 files changed, 43 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/931dc527/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f6dd825..bb2cafb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@
     </parent>
     <artifactId>commons-release-plugin</artifactId>
     <packaging>maven-plugin</packaging>
-    <version>1.1-SNAPSHOT</version>
+    <version>1.2-SNAPSHOT</version>
     <name>Apache Commons Release Plugin</name>
 
     <description>

http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/931dc527/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java
index 6b79e0f..72f632c 100644
--- a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java
+++ b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java
@@ -82,23 +82,32 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo {
     /**
      * The working directory in <code>target</code> that we use as a sandbox for the plugin.
      */
-    @Parameter(defaultValue = "${project.build.directory}/commons-release-plugin", alias = "outputDirectory")
+    @Parameter(defaultValue = "${project.build.directory}/commons-release-plugin",
+            property = "commons.outputDirectory")
     private File workingDirectory;
 
     /**
      * The subversion staging url to which we upload all of our staged artifacts.
      */
-    @Parameter(required = true)
+    @Parameter(defaultValue = "", property = "commons.distSvnStagingUrl")
     private String distSvnStagingUrl;
 
     @Override
     public void execute() throws MojoExecutionException {
+        if ("".equals(distSvnStagingUrl)) {
+            getLog().warn("commons.distSvnStagingUrl is not set, the commons-release-plugin will not run");
+            return;
+        }
         getLog().info("Detaching Assemblies");
         for (Object attachedArtifact : project.getAttachedArtifacts()) {
             if (ARTIFACT_TYPES_TO_DETACH.contains(((Artifact) attachedArtifact).getType())) {
                 detachedArtifacts.add((Artifact) attachedArtifact);
             }
         }
+        if (detachedArtifacts.isEmpty()) {
+            getLog().info("Current project contains no distributions. Not executing.");
+            return;
+        }
         for (Artifact artifactToRemove : detachedArtifacts) {
             project.getAttachedArtifacts().remove(artifactToRemove);
         }

http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/931dc527/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java
index aef8e24..1eb36c3 100644
--- a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java
+++ b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java
@@ -73,20 +73,21 @@ public class CommonsDistributionStagingMojo extends AbstractMojo {
      * The main working directory for the plugin, namely <code>target/commons-release-plugin</code>, but
      * that assumes that we're using the default maven <code>${project.build.directory}</code>.
      */
-    @Parameter(defaultValue = "${project.build.directory}/commons-release-plugin", alias = "outputDirectory")
+    @Parameter(defaultValue = "${project.build.directory}/commons-release-plugin", property = "commons.outputDirectory")
     private File workingDirectory;
 
     /**
      * The location to which to checkout the dist subversion repository under our working directory, which
      * was given above.
      */
-    @Parameter(defaultValue = "${project.build.directory}/commons-release-plugin/scm", alias = "distCheckoutDirectory")
+    @Parameter(defaultValue = "${project.build.directory}/commons-release-plugin/scm",
+            property = "commons.distCheckoutDirectory")
     private File distCheckoutDirectory;
 
     /**
      * The location of the RELEASE-NOTES.txt file such that multimodule builds can configure it.
      */
-    @Parameter(defaultValue = "${basedir}/RELEASE-NOTES.txt", alias = "releaseNotesLocation")
+    @Parameter(defaultValue = "${basedir}/RELEASE-NOTES.txt", property = "commons.releaseNotesLocation")
     private File releaseNotesFile;
 
     /**
@@ -103,7 +104,7 @@ public class CommonsDistributionStagingMojo extends AbstractMojo {
      * <code>scm:svn:https://dist.apache.org/repos/dist/dev/commons/foo</code>. Note. that the prefix to the
      * substring <code>https</code> is a requirement.
      */
-    @Parameter(required = true)
+    @Parameter(defaultValue = "", property = "commons.distSvnStagingUrl")
     private String distSvnStagingUrl;
 
     /**
@@ -120,6 +121,14 @@ public class CommonsDistributionStagingMojo extends AbstractMojo {
 
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
+        if ("".equals(distSvnStagingUrl)) {
+            getLog().warn("commons.distSvnStagingUrl is not set, the commons-release-plugin will not run");
+            return;
+        }
+        if (!workingDirectory.exists()) {
+            getLog().info("Current project contains no distributions. Not executing.");
+            return;
+        }
         getLog().info("Preparing to stage distributions");
         try {
             ScmManager scmManager = new BasicScmManager();
@@ -129,9 +138,6 @@ public class CommonsDistributionStagingMojo extends AbstractMojo {
             SvnScmProviderRepository providerRepository = (SvnScmProviderRepository) repository.getProviderRepository();
             providerRepository.setUser(username);
             providerRepository.setPassword(password);
-            if (!workingDirectory.exists()) {
-                SharedFunctions.initDirectory(getLog(), workingDirectory);
-            }
             if (!distCheckoutDirectory.exists()) {
                 SharedFunctions.initDirectory(getLog(), distCheckoutDirectory);
             }

http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/931dc527/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java
index 8d67dda..d4af916 100644
--- a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java
+++ b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsSiteCompressionMojo.java
@@ -52,15 +52,25 @@ public class CommonsSiteCompressionMojo extends AbstractMojo {
      * The working directory for the plugin which, assuming the maven uses the default
      * <code>${project.build.directory}</code>, this becomes <code>target/commons-release-plugin</code>.
      */
-    @Parameter(defaultValue = "${project.build.directory}/commons-release-plugin", alias = "outputDirectory")
+    @Parameter(defaultValue = "${project.build.directory}/commons-release-plugin",
+            property = "commons.outputDirectory")
     private File workingDirectory;
 
     /**
      */
-    @Parameter(defaultValue = "${project.build.directory}/site", alias = "siteOutputDirectory")
+    @Parameter(defaultValue = "${project.build.directory}/site", property = "commons.siteOutputDirectory")
     private File siteDirectory;
 
     /**
+     * The url of the subversion repository to which we wish the artifacts to be staged. Typicallly
+     * this would need to be of the form:
+     * <code>scm:svn:https://dist.apache.org/repos/dist/dev/commons/foo</code>. Note. that the prefix to the
+     * substring <code>https</code> is a requirement.
+     */
+    @Parameter(defaultValue = "", property = "commons.distSvnStagingUrl")
+    private String distSvnStagingUrl;
+
+    /**
      * A variable for the process of creating the site.zip file.
      */
     private ScatterZipOutputStream dirs;
@@ -77,6 +87,10 @@ public class CommonsSiteCompressionMojo extends AbstractMojo {
 
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
+        if ("".equals(distSvnStagingUrl)) {
+            getLog().warn("commons.distSvnStagingUrl is not set, the commons-release-plugin will not run");
+            return;
+        }
         if (!siteDirectory.exists()) {
             getLog().error("\"mvn site\" was not run before this goal, or a siteDirectory did not exist.");
             throw new MojoFailureException(
@@ -84,7 +98,8 @@ public class CommonsSiteCompressionMojo extends AbstractMojo {
             );
         }
         if (!workingDirectory.exists()) {
-            SharedFunctions.initDirectory(getLog(), workingDirectory);
+            getLog().info("Current project contains no distributions. Not executing.");
+            return;
         }
         try {
             filesToCompress = new ArrayList<>();