You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by bi...@apache.org on 2012/08/31 17:55:51 UTC

svn commit: r1379486 - /maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java

Author: bimargulies
Date: Fri Aug 31 15:55:50 2012
New Revision: 1379486

URL: http://svn.apache.org/viewvc?rev=1379486&view=rev
Log:
MSHADE-130, MSHADE-124: Mark mojo as threadSafe for parallel builds, Need better plan for getting dependency-reduced-pom.xml out of basedir
o put thread safe back, and start on unique name alternative solution to MSHADE-124.

Modified:
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java

Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java?rev=1379486&r1=1379485&r2=1379486&view=diff
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java (original)
+++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java Fri Aug 31 15:55:50 2012
@@ -90,7 +90,7 @@ import java.util.Set;
  * @author David Blevins
  * @author Hiram Chirino
  */
-@Mojo( name = "shade", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = false,
+@Mojo( name = "shade", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true,
        requiresDependencyResolution = ResolutionScope.RUNTIME )
 public class ShadeMojo
     extends AbstractMojo
@@ -295,6 +295,16 @@ public class ShadeMojo
     private File dependencyReducedPomLocation;
 
     /**
+     * Create a dependency-reduced POM in ${basedir}/drp-UNIQUE.pom. This avoids build collisions
+     * of parallel builds without moving the dependency-reduced POM to a different directory.
+     * The property maven.shade.dependency-reduced-pom is set to the generated filename.
+     *
+     * @since 1.7.2
+     */
+    @Parameter
+    private boolean generateUniqueDependencyReducedPom;
+
+    /**
      * When true, dependencies are kept in the pom but with scope 'provided'; when false,
      * the dependency is removed.
      */
@@ -868,10 +878,18 @@ public class ShadeMojo
 
                 model.setDependencies( dependencies );
 
-                if ( dependencyReducedPomLocation == null )
+                if ( generateUniqueDependencyReducedPom )
                 {
-                    // MSHADE-123: We can't default to 'target' because it messes up uses of ${project.basedir}
-                    dependencyReducedPomLocation = new File( project.getBasedir(), "dependency-reduced-pom.xml" );
+                    dependencyReducedPomLocation = File.createTempFile( "dependency-reduced-pom", "xml", project.getBasedir() );
+                    project.getProperties().setProperty( "maven.shade.dependency-reduced-pom", dependencyReducedPomLocation.getAbsolutePath() );
+                }
+                else
+                {
+                    if ( dependencyReducedPomLocation == null )
+                    {
+                        // MSHADE-123: We can't default to 'target' because it messes up uses of ${project.basedir}
+                        dependencyReducedPomLocation = new File( project.getBasedir(), "dependency-reduced-pom.xml" );
+                    }
                 }
 
                 File f = dependencyReducedPomLocation;