You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by se...@apache.org on 2013/06/27 02:20:30 UTC

svn commit: r1497157 - in /maven/sandbox/trunk/plugins/maven-digest-plugin/src/main/java/org/apache/maven/plugins/digest: DigestCreateMojo.java HelperMojo.java

Author: sebb
Date: Thu Jun 27 00:20:29 2013
New Revision: 1497157

URL: http://svn.apache.org/r1497157
Log:
Allow plugin to be used outside a project

Modified:
    maven/sandbox/trunk/plugins/maven-digest-plugin/src/main/java/org/apache/maven/plugins/digest/DigestCreateMojo.java
    maven/sandbox/trunk/plugins/maven-digest-plugin/src/main/java/org/apache/maven/plugins/digest/HelperMojo.java

Modified: maven/sandbox/trunk/plugins/maven-digest-plugin/src/main/java/org/apache/maven/plugins/digest/DigestCreateMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-digest-plugin/src/main/java/org/apache/maven/plugins/digest/DigestCreateMojo.java?rev=1497157&r1=1497156&r2=1497157&view=diff
==============================================================================
--- maven/sandbox/trunk/plugins/maven-digest-plugin/src/main/java/org/apache/maven/plugins/digest/DigestCreateMojo.java (original)
+++ maven/sandbox/trunk/plugins/maven-digest-plugin/src/main/java/org/apache/maven/plugins/digest/DigestCreateMojo.java Thu Jun 27 00:20:29 2013
@@ -14,6 +14,7 @@
 
 package org.apache.maven.plugins.digest;
 
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -37,7 +38,7 @@ import org.codehaus.plexus.util.Director
  * Creates digests (MD5 and SHA1 by default) for files specified by the configured includes and excludes. Also allows
  * specification of a list of files on the command line.
  */
-@Mojo( name = "create" )
+@Mojo( name = "create", requiresProject=false )
 public class DigestCreateMojo
     extends AbstractMojo
 {
@@ -226,7 +227,11 @@ public class DigestCreateMojo
     {
         DirectoryScanner ds = new DirectoryScanner();
         ds.setFollowSymlinks( true );
-        ds.setBasedir( project.getBasedir() ); // Cannot be omitted; implies that includes/excludes are relative
+        File basedir = project.getBasedir();
+        if (basedir == null) {
+            basedir = new File("."); // current directory
+        }
+        ds.setBasedir( basedir ); // Cannot be omitted; implies that includes/excludes are relative
         String[] inc;
         if ( files != null )
         { // Overrides includes / excludes

Modified: maven/sandbox/trunk/plugins/maven-digest-plugin/src/main/java/org/apache/maven/plugins/digest/HelperMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-digest-plugin/src/main/java/org/apache/maven/plugins/digest/HelperMojo.java?rev=1497157&r1=1497156&r2=1497157&view=diff
==============================================================================
--- maven/sandbox/trunk/plugins/maven-digest-plugin/src/main/java/org/apache/maven/plugins/digest/HelperMojo.java (original)
+++ maven/sandbox/trunk/plugins/maven-digest-plugin/src/main/java/org/apache/maven/plugins/digest/HelperMojo.java Thu Jun 27 00:20:29 2013
@@ -30,7 +30,7 @@ import org.apache.maven.project.MavenPro
  * Helper Mojo that extends the standard Maven help plugin describe goal. This is needed because the generated help mojo
  * does not handle annotation property names at present.
  */
-@Mojo( name = "help" )
+@Mojo( name = "help", requiresProject = false )
 public class HelperMojo
     extends DescribeMojo
 {
@@ -39,9 +39,6 @@ public class HelperMojo
     // Mojo components
     // ----------------------------------------------------------------------
 
-    @Component
-    private MavenProject myProject; // Must not use same name as DescribeMojo
-
     // ----------------------------------------------------------------------
     // Mojo parameters
     // ----------------------------------------------------------------------
@@ -72,7 +69,10 @@ public class HelperMojo
             {
                 f.setAccessible( true );
             }
-            String plugin = myProject.getGroupId() + ":" + myProject.getArtifactId();
+            // N.B. Customise for each plugin
+            // We used to use project component to get the info, but that forces plugin to be used in a project
+            // Plugin should be able to be used standalone
+            final String plugin = "org.apache.maven.plugins:maven-digest-plugin";
             f.set( this, plugin );
             super.execute();
         }