You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2006/06/21 22:44:23 UTC
svn commit: r416104 - in /maven/plugins/trunk/maven-assembly-plugin: pom.xml
src/main/java/org/apache/maven/plugin/assembly/AbstractAssemblyMojo.java
Author: jdcasey
Date: Wed Jun 21 13:44:23 2006
New Revision: 416104
URL: http://svn.apache.org/viewvc?rev=416104&view=rev
Log:
[MASSEMBLY-120] Added implementation of filtering for <binaries/> inside of <moduleSet/> in the assembly descriptor. Correct usage is same as for dependencySet includes/excludes.
Also, altered the pom.xml to use maven-archiver 2.0.4, to enable development to continue prior to the release of Maven 2.1. It seemed to build fine with tests, despite a comment to the contrary in the pom.
Modified:
maven/plugins/trunk/maven-assembly-plugin/pom.xml
maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractAssemblyMojo.java
Modified: maven/plugins/trunk/maven-assembly-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/pom.xml?rev=416104&r1=416103&r2=416104&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-assembly-plugin/pom.xml Wed Jun 21 13:44:23 2006
@@ -17,9 +17,11 @@
<plugin>
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>
+ <version>1.0-alpha-8</version>
<executions>
<execution>
<id>descriptor</id>
+ <phase>generate-sources</phase>
<goals>
<goal>xpp3-reader</goal>
<goal>xpp3-writer</goal>
@@ -33,6 +35,7 @@
</execution>
<execution>
<id>component</id>
+ <phase>generate-sources</phase>
<goals>
<goal>xpp3-reader</goal>
<goal>java</goal>
@@ -102,7 +105,8 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-archiver</artifactId>
- <version>2.1-SNAPSHOT</version>
+ <version>2.0.4</version>
+ <!-- version>2.1-SNAPSHOT</version -->
<!-- XXX: A bug in Maven 2.0.4 means this will block necessary dependencies coming through the testing harness -->
<exclusions>
<exclusion>
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractAssemblyMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractAssemblyMojo.java?rev=416104&r1=416103&r2=416104&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractAssemblyMojo.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractAssemblyMojo.java Wed Jun 21 13:44:23 2006
@@ -457,15 +457,15 @@
{
ModuleSet moduleSet = (ModuleSet) i.next();
- AndArtifactFilter filter = new AndArtifactFilter();
+ AndArtifactFilter moduleFilter = new AndArtifactFilter();
if ( !moduleSet.getIncludes().isEmpty() )
{
- filter.add( new AssemblyIncludesArtifactFilter( moduleSet.getIncludes() ) );
+ moduleFilter.add( new AssemblyIncludesArtifactFilter( moduleSet.getIncludes() ) );
}
if ( !moduleSet.getExcludes().isEmpty() )
{
- filter.add( new AssemblyExcludesArtifactFilter( moduleSet.getExcludes() ) );
+ moduleFilter.add( new AssemblyExcludesArtifactFilter( moduleSet.getExcludes() ) );
}
Set set = getModulesFromReactor( getExecutedProject() );
@@ -476,7 +476,7 @@
{
MavenProject moduleProject = (MavenProject) j.next();
- if ( filter.include( moduleProject.getArtifact() ) )
+ if ( moduleFilter.include( moduleProject.getArtifact() ) )
{
String name = moduleProject.getBuild().getFinalName();
@@ -513,9 +513,9 @@
if ( binaries != null )
{
- Artifact artifact = moduleProject.getArtifact();
+ Artifact moduleArtifact = moduleProject.getArtifact();
- if ( artifact.getFile() == null )
+ if ( moduleArtifact.getFile() == null )
{
throw new MojoExecutionException( "Included module: " + moduleProject.getId() +
" does not have an artifact with a file. Please ensure the package phase is run before the assembly is generated." );
@@ -532,6 +532,32 @@
Integer.toString( archiver.getDefaultDirectoryMode(), 8 ) + " file perms: " +
Integer.toString( archiver.getDefaultFileMode(), 8 ) );
+ Set binaryDependencies = moduleProject.getArtifacts();
+
+ List includes = binaries.getIncludes();
+ List excludes = binaries.getExcludes();
+
+ AndArtifactFilter binaryDepsFilter = new AndArtifactFilter();
+
+ if ( !includes.isEmpty() )
+ {
+ binaryDepsFilter.add( new AssemblyIncludesArtifactFilter( includes ) );
+ }
+ if ( !excludes.isEmpty() )
+ {
+ binaryDepsFilter.add( new AssemblyExcludesArtifactFilter( excludes ) );
+ }
+
+ for ( Iterator it = binaryDependencies.iterator(); it.hasNext(); )
+ {
+ Artifact binaryDepArtifact = (Artifact) it.next();
+
+ if ( !binaryDepsFilter.include( binaryDepArtifact ) )
+ {
+ binaryDependencies.remove( binaryDepArtifact );
+ }
+ }
+
if ( binaries.isUnpack() )
{
// TODO: something like zipfileset in plexus-archiver
@@ -545,7 +571,7 @@
tempLocation.mkdirs();
process = true;
}
- else if ( artifact.getFile().lastModified() > tempLocation.lastModified() )
+ else if ( moduleArtifact.getFile().lastModified() > tempLocation.lastModified() )
{
process = true;
}
@@ -554,15 +580,13 @@
{
try
{
- unpack( artifact.getFile(), tempLocation );
+ unpack( moduleArtifact.getFile(), tempLocation );
if ( binaries.isIncludeDependencies() )
{
- Set artifactSet = moduleProject.getArtifacts();
-
- for ( Iterator artifacts = artifactSet.iterator(); artifacts.hasNext(); )
+ for ( Iterator dependencyIterator = binaryDependencies.iterator(); dependencyIterator.hasNext(); )
{
- Artifact dependencyArtifact = (Artifact) artifacts.next();
+ Artifact dependencyArtifact = (Artifact) dependencyIterator.next();
unpack( dependencyArtifact.getFile(), tempLocation );
}
@@ -611,14 +635,12 @@
{
String outputFileNameMapping = binaries.getOutputFileNameMapping();
- archiver.addFile( artifact.getFile(),
- output + evaluateFileNameMapping( artifact, outputFileNameMapping ) );
+ archiver.addFile( moduleArtifact.getFile(),
+ output + evaluateFileNameMapping( moduleArtifact, outputFileNameMapping ) );
if ( binaries.isIncludeDependencies() )
{
- Set artifactSet = moduleProject.getArtifacts();
-
- for ( Iterator artifacts = artifactSet.iterator(); artifacts.hasNext(); )
+ for ( Iterator artifacts = binaryDependencies.iterator(); artifacts.hasNext(); )
{
Artifact dependencyArtifact = (Artifact) artifacts.next();