maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r468451 - in /maven/plugins/trunk/maven-assembly-plugin/src: it/descriptor-refs/src/ it/descriptor-refs/src/src-dir-copied/ it/file-sets/include-parent-dir/ it/file-sets/include-parent-dir/child/ it/file-sets/include-parent-dir/child/src/ i...
Date Fri, 27 Oct 2006 16:49:55 GMT
Author: jdcasey
Date: Fri Oct 27 09:49:53 2006
New Revision: 468451

URL: http://svn.apache.org/viewvc?view=rev&rev=468451
Log:
[MASSEMBLY-113][MASSEMBLY-106] Verified proper behavior when '..' directory is used in a fileSet,
and added ability to specify <attachmentClassifier/> element in <binaries/> under
a module set. When the classifier is specified, any module in that set that doesn't have a
matching attachment will cause the assembly to fail. Otherwise, the attached artifact is used
instead of the project artifact.

Added:
    maven/plugins/trunk/maven-assembly-plugin/src/it/descriptor-refs/src/
    maven/plugins/trunk/maven-assembly-plugin/src/it/descriptor-refs/src/src-dir-copied/
    maven/plugins/trunk/maven-assembly-plugin/src/it/descriptor-refs/src/src-dir-copied/pom.xml
  (with props)
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/pom.xml
  (with props)
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/assemble/
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/assemble/parent.xml
  (with props)
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/main/
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/main/java/
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/main/java/test/
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/main/java/test/App.java
  (with props)
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/test/
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/test/java/
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/test/java/test/
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/test/java/test/AppTest.java
  (with props)
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/goals.txt
  (with props)
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/pom.xml
  (with props)
    maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/verify.bsh
Modified:
    maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/phase/ModuleSetAssemblyPhase.java
    maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddDirectoryTask.java
    maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/descriptor.mdo
    maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java

Added: maven/plugins/trunk/maven-assembly-plugin/src/it/descriptor-refs/src/src-dir-copied/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/descriptor-refs/src/src-dir-copied/pom.xml?view=auto&rev=468451
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/it/descriptor-refs/src/src-dir-copied/pom.xml
(added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/it/descriptor-refs/src/src-dir-copied/pom.xml
Fri Oct 27 09:49:53 2006
@@ -0,0 +1,39 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>test</groupId>
+  <artifactId>src-dir-copied</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>Maven Quick Start Archetype</name>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>assembly</id>
+            <phase>package</phase>
+            <goals>
+              <goal>attached</goal>
+            </goals>
+            <configuration>
+              <descriptorRefs>
+                <descriptorRef>src</descriptorRef>
+              </descriptorRefs>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/plugins/trunk/maven-assembly-plugin/src/it/descriptor-refs/src/src-dir-copied/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/pom.xml?view=auto&rev=468451
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/pom.xml
(added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/pom.xml
Fri Oct 27 09:49:53 2006
@@ -0,0 +1,42 @@
+<?xml version="1.0"?><project>
+  <parent>
+    <artifactId>include-parent-dir</artifactId>
+    <groupId>test</groupId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>test</groupId>
+  <artifactId>child</artifactId>
+  <name>Maven Quick Start Archetype</name>
+  <version>1.0-SNAPSHOT</version>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <descriptors>
+            <descriptor>src/assemble/parent.xml</descriptor>
+          </descriptors>
+        </configuration>
+        <executions>
+          <execution>
+            <id>build-parent-assembly</id>
+            <phase>package</phase>
+            <goals>
+              <goal>directory-single</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/assemble/parent.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/assemble/parent.xml?view=auto&rev=468451
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/assemble/parent.xml
(added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/assemble/parent.xml
Fri Oct 27 09:49:53 2006
@@ -0,0 +1,17 @@
+<assembly>
+  <id>parent</id>
+  <formats>
+    <format>dir</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <fileSets>
+    <fileSet>
+      <directory>..</directory>
+      <outputDirectory></outputDirectory>
+      <useDefaultExcludes>true</useDefaultExcludes>
+      <excludes>
+        <exclude>**/target/**</exclude>
+      </excludes>
+    </fileSet>
+  </fileSets>
+</assembly>

Propchange: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/assemble/parent.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/assemble/parent.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/main/java/test/App.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/main/java/test/App.java?view=auto&rev=468451
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/main/java/test/App.java
(added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/main/java/test/App.java
Fri Oct 27 09:49:53 2006
@@ -0,0 +1,13 @@
+package test;
+
+/**
+ * Hello world!
+ *
+ */
+public class App 
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}

Propchange: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/main/java/test/App.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/main/java/test/App.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/test/java/test/AppTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/test/java/test/AppTest.java?view=auto&rev=468451
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/test/java/test/AppTest.java
(added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/test/java/test/AppTest.java
Fri Oct 27 09:49:53 2006
@@ -0,0 +1,38 @@
+package test;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest 
+    extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertTrue( true );
+    }
+}

Propchange: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/test/java/test/AppTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/child/src/test/java/test/AppTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/goals.txt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/goals.txt?view=auto&rev=468451
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/goals.txt
(added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/goals.txt
Fri Oct 27 09:49:53 2006
@@ -0,0 +1 @@
+package

Propchange: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/goals.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/goals.txt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/pom.xml?view=auto&rev=468451
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/pom.xml
(added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/pom.xml
Fri Oct 27 09:49:53 2006
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>test</groupId>
+  <artifactId>include-parent-dir</artifactId>
+  <packaging>pom</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>Maven Quick Start Archetype</name>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <modules>
+    <module>child</module>
+  </modules>
+</project>
\ No newline at end of file

Propchange: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/verify.bsh?view=auto&rev=468451
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/verify.bsh
(added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/it/file-sets/include-parent-dir/verify.bsh
Fri Oct 27 09:49:53 2006
@@ -0,0 +1,3 @@
+import java.io.*;
+
+return new File( basedir, "child/target/child-1.0-SNAPSHOT-parent.dir/child/pom.xml" ).exists();

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/phase/ModuleSetAssemblyPhase.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/phase/ModuleSetAssemblyPhase.java?view=diff&rev=468451&r1=468450&r2=468451
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/phase/ModuleSetAssemblyPhase.java
(original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/phase/ModuleSetAssemblyPhase.java
Fri Oct 27 09:49:53 2006
@@ -116,14 +116,45 @@
                 it.remove();
             }
         }
+        
+        String classifier = binaries.getAttachmentClassifier();
 
         for ( Iterator j = moduleProjects.iterator(); j.hasNext(); )
         {
             MavenProject project = ( MavenProject ) j.next();
 
-            getLogger().debug( "Processing binary artifact for module project: " + project.getId()
);
+            Artifact artifact = null;
+            
+            if ( classifier == null )
+            {
+                getLogger().debug( "Processing binary artifact for module project: " + project.getId()
);
 
-            Artifact artifact = project.getArtifact();
+                artifact = project.getArtifact();
+            }
+            else
+            {
+                getLogger().debug( "Processing binary attachment: " + classifier + " for
module project: " + project.getId() );
+
+                List attachments = project.getAttachedArtifacts();
+                if ( attachments != null && !attachments.isEmpty() )
+                {
+                    for ( Iterator attachmentIterator = attachments.iterator(); attachmentIterator.hasNext();
)
+                    {
+                        Artifact attachment = (Artifact) attachmentIterator.next();
+                        
+                        if ( classifier.equals( attachment.getClassifier() ) )
+                        {
+                            artifact = attachment;
+                            break;
+                        }
+                    }
+                }
+                
+                if ( artifact == null )
+                {
+                    throw new InvalidAssemblerConfigurationException( "Cannot find attachment
with classifier: " + classifier + " in module project: " + project.getId() + ". Please exclude
this module from the module-set." );
+                }
+            }
 
             addArtifact( artifact, project, archiver, configSource, binaries );
         }

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddDirectoryTask.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddDirectoryTask.java?view=diff&rev=468451&r1=468450&r2=468451
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddDirectoryTask.java
(original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddDirectoryTask.java
Fri Oct 27 09:49:53 2006
@@ -13,13 +13,19 @@
 public class AddDirectoryTask
     implements ArchiverTask
 {
-    
+
     private final File directory;
+
     private List includes;
+
     private List excludes;
+
     private String outputDirectory;
+
     private boolean useDefaultExcludes = true;
+
     private int directoryMode = -1;
+
     private int fileMode = -1;
 
     public AddDirectoryTask( File directory )
@@ -30,6 +36,16 @@
     public void execute( Archiver archiver, AssemblerConfigurationSource configSource )
         throws ArchiveCreationException
     {
+        if ( ".".equals( outputDirectory ) )
+        {
+            outputDirectory = "";
+        }
+        else if ( "..".equals( outputDirectory ) )
+        {
+            throw new ArchiveCreationException( "Cannot add source directory: " + directory
+ " to archive-path: "
+                + outputDirectory + ". All paths must be within the archive root directory."
);
+        }
+
         int oldDirMode = archiver.getDefaultDirectoryMode();
         int oldFileMode = archiver.getDefaultFileMode();
 
@@ -39,7 +55,7 @@
             {
                 archiver.setDefaultDirectoryMode( directoryMode );
             }
-            
+
             if ( fileMode > -1 )
             {
                 archiver.setDefaultFileMode( fileMode );
@@ -56,7 +72,7 @@
                 {
                     directoryExcludes = new ArrayList();
                 }
-                
+
                 if ( useDefaultExcludes )
                 {
                     directoryExcludes.addAll( FileUtils.getDefaultExcludesAsList() );

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/descriptor.mdo
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/descriptor.mdo?view=diff&rev=468451&r1=468450&r2=468451
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/descriptor.mdo (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/descriptor.mdo Fri Oct 27 09:49:53
2006
@@ -641,6 +641,17 @@
       </description>
       <fields>
         <field>
+          <name>attachmentClassifier</name>
+          <version>1.1.0</version>
+          <type>String</type>
+          <description>
+          When specified, the attachmentClassifier will cause the assembler to look at artifacts
+          attached to the module instead of the main project artifact. If it can find an
attached
+          artifact matching the specified classifier, it will use it; otherwise, it will
throw an
+          exception.
+          </description>
+        </field>
+        <field>
           <name>includeDependencies</name>
           <version>1.0.0+</version>
           <type>boolean</type>

Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java?view=diff&rev=468451&r1=468450&r2=468451
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java
(original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java
Fri Oct 27 09:49:53 2006
@@ -126,8 +126,9 @@
 
         mm.replayAll();
 
-        FileSet result =
-            createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), null ).createFileSet(
fs, sources, project );
+        FileSet result = createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), null
).createFileSet( fs,
+                                                                                        
                    sources,
+                                                                                        
                    project );
 
         assertEquals( "artifact/", result.getOutputDirectory() );
 
@@ -164,8 +165,9 @@
 
         mm.replayAll();
 
-        FileSet result =
-            createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), null ).createFileSet(
fs, sources, project );
+        FileSet result = createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), null
).createFileSet( fs,
+                                                                                        
                    sources,
+                                                                                        
                    project );
 
         assertEquals( "artifact/out/", result.getOutputDirectory() );
 
@@ -203,8 +205,9 @@
 
         mm.replayAll();
 
-        FileSet result =
-            createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), null ).createFileSet(
fs, sources, project );
+        FileSet result = createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), null
).createFileSet( fs,
+                                                                                        
                    sources,
+                                                                                        
                    project );
 
         assertEquals( 1, result.getExcludes().size() );
         assertEquals( "submodule/**", result.getExcludes().get( 0 ) );
@@ -312,6 +315,83 @@
         mm.verifyAll();
     }
 
+    public void testAddModuleBinaries_ShouldAddOneModuleAttachmentArtifactAndNoDeps()
+        throws ArchiveCreationException, AssemblyFormattingException, IOException,
+        InvalidAssemblerConfigurationException
+    {
+        MockManager mm = new MockManager();
+
+        MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(
mm );
+
+        macTask.expectArtifactGetFile( true );
+        macTask.expectGetClassifier( "test" );
+        macTask.expectGetFinalName( "final-name" );
+        macTask.expectIsSnapshot( false );
+        macTask.expectGetArtifactHandler();
+        macTask.expectAddFile( "out/artifact-test", Integer.parseInt( "777", 8 ) );
+
+        ModuleBinaries binaries = new ModuleBinaries();
+
+        binaries.setUnpack( false );
+        binaries.setFileMode( "777" );
+        binaries.setOutputDirectory( "out" );
+        binaries.setOutputFileNameMapping( "artifact" );
+        binaries.setAttachmentClassifier( "test" );
+
+        MavenProject project = createProject( "group", "artifact", "version", null );
+        project.addAttachedArtifact( macTask.artifact );
+
+        Set projects = Collections.singleton( project );
+
+        mm.replayAll();
+
+        Logger logger = new ConsoleLogger( Logger.LEVEL_DEBUG, "test" );
+
+        createPhase( logger, null ).addModuleBinaries( binaries, projects, macTask.archiver,
macTask.configSource );
+
+        mm.verifyAll();
+    }
+
+    public void testAddModuleBinaries_ShouldFailWhenOneModuleDoesntHaveAttachmentWithMatchingClassifier()
+        throws ArchiveCreationException, AssemblyFormattingException, IOException
+    {
+        MockManager mm = new MockManager();
+
+        MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(
mm );
+
+        macTask.expectArtifactGetFile( true );
+
+        ModuleBinaries binaries = new ModuleBinaries();
+
+        binaries.setUnpack( false );
+        binaries.setFileMode( "777" );
+        binaries.setOutputDirectory( "out" );
+        binaries.setOutputFileNameMapping( "artifact" );
+        binaries.setAttachmentClassifier( "test" );
+
+        MavenProject project = createProject( "group", "artifact", "version", null );
+        project.setArtifact( macTask.artifact );
+
+        Set projects = Collections.singleton( project );
+
+        mm.replayAll();
+
+        Logger logger = new ConsoleLogger( Logger.LEVEL_DEBUG, "test" );
+
+        try
+        {
+            createPhase( logger, null ).addModuleBinaries( binaries, projects, macTask.archiver,
macTask.configSource );
+            
+            fail( "Should throw an invalid configuration exception because of module with
missing attachment." );
+        }
+        catch ( InvalidAssemblerConfigurationException e )
+        {
+            // should throw this because of missing attachment.
+        }
+
+        mm.verifyAll();
+    }
+
     public void testAddModuleBinaries_ShouldAddOneModuleArtifactAndNoDeps()
         throws ArchiveCreationException, AssemblyFormattingException, IOException,
         InvalidAssemblerConfigurationException
@@ -492,10 +572,8 @@
 
         Set artifactIds = Collections.singleton( "group:artifact:jar" );
 
-        List result =
-            createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), null ).collectExcludesFromQueuedArtifacts(
-                                                                                        
                            artifactIds,
-                                                                                        
                            excludes );
+        List result = createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), null
)
+            .collectExcludesFromQueuedArtifacts( artifactIds, excludes );
 
         assertEquals( 1, result.size() );
 
@@ -512,10 +590,8 @@
 
         Set artifactIds = Collections.singleton( "group:artifact:jar" );
 
-        List result =
-            createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), null ).collectExcludesFromQueuedArtifacts(
-                                                                                        
                            artifactIds,
-                                                                                        
                            null );
+        List result = createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), null
)
+            .collectExcludesFromQueuedArtifacts( artifactIds, null );
 
         assertEquals( 1, result.size() );
 
@@ -663,11 +739,8 @@
 
         mm.replayAll();
 
-        Set moduleProjects =
-            createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), macTask ).getModuleProjects(
-                                                                                        
              moduleSet,
-                                                                                        
              macTask.configSource,
-                                                                                        
              true );
+        Set moduleProjects = createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ),
macTask )
+            .getModuleProjects( moduleSet, macTask.configSource, true );
 
         assertTrue( moduleProjects.isEmpty() );
 
@@ -695,11 +768,8 @@
 
         mm.replayAll();
 
-        Set moduleProjects =
-            createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), macTask ).getModuleProjects(
-                                                                                        
              moduleSet,
-                                                                                        
              macTask.configSource,
-                                                                                        
              true );
+        Set moduleProjects = createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ),
macTask )
+            .getModuleProjects( moduleSet, macTask.configSource, true );
 
         assertTrue( moduleProjects.isEmpty() );
 
@@ -727,15 +797,12 @@
 
         mm.replayAll();
 
-        Set moduleProjects =
-            createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), macTask ).getModuleProjects(
-                                                                                        
              moduleSet,
-                                                                                        
              macTask.configSource,
-                                                                                        
              true );
+        Set moduleProjects = createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ),
macTask )
+            .getModuleProjects( moduleSet, macTask.configSource, true );
 
         assertFalse( moduleProjects.isEmpty() );
 
-        MavenProject result = ( MavenProject ) moduleProjects.iterator().next();
+        MavenProject result = (MavenProject) moduleProjects.iterator().next();
 
         assertEquals( "artifact2", result.getArtifactId() );
 
@@ -765,11 +832,8 @@
 
         mm.replayAll();
 
-        Set moduleProjects =
-            createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), macTask ).getModuleProjects(
-                                                                                        
              moduleSet,
-                                                                                        
              macTask.configSource,
-                                                                                        
              true );
+        Set moduleProjects = createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ),
macTask )
+            .getModuleProjects( moduleSet, macTask.configSource, true );
 
         assertEquals( 2, moduleProjects.size() );
 
@@ -797,13 +861,14 @@
         MavenProject project2 = createProject( "group", "artifact2", "version", project );
         macArtifacts.add( addArtifact( project2, mm, true, false ) );
 
-        ( ( MockAndControlForArtifact ) macArtifacts.get( 1 ) ).expectGetId( "group:artifact2:jar:version"
);
-        ( ( MockAndControlForArtifact ) macArtifacts.get( 1 ) ).expectGetDependencyTrail(
Collections.singletonList( "group:artifact:jar:version" ) );
+        ( (MockAndControlForArtifact) macArtifacts.get( 1 ) ).expectGetId( "group:artifact2:jar:version"
);
+        ( (MockAndControlForArtifact) macArtifacts.get( 1 ) ).expectGetDependencyTrail( Collections
+            .singletonList( "group:artifact:jar:version" ) );
 
         MavenProject project3 = createProject( "group", "artifact3", "version", project2
);
         macArtifacts.add( addArtifact( project3, mm, true, true ) );
 
-        ( ( MockAndControlForArtifact ) macArtifacts.get( 2 ) ).expectGetId( "group:artifact3:jar:version"
);
+        ( (MockAndControlForArtifact) macArtifacts.get( 2 ) ).expectGetId( "group:artifact3:jar:version"
);
 
         List projects = new ArrayList();
         projects.add( project );
@@ -819,11 +884,8 @@
 
         mm.replayAll();
 
-        Set moduleProjects =
-            createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), macTask ).getModuleProjects(
-                                                                                        
              moduleSet,
-                                                                                        
              macTask.configSource,
-                                                                                        
              true );
+        Set moduleProjects = createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ),
macTask )
+            .getModuleProjects( moduleSet, macTask.configSource, true );
 
         assertTrue( moduleProjects.isEmpty() );
 
@@ -839,8 +901,8 @@
         {
             macArtifact.expectGetArtifactId( project.getArtifactId() );
             macArtifact.expectGetGroupId( project.getGroupId() );
-            macArtifact.expectGetDependencyConflictId( project.getGroupId(), project.getArtifactId(),
-                                                       project.getPackaging() );
+            macArtifact.expectGetDependencyConflictId( project.getGroupId(), project.getArtifactId(),
project
+                .getPackaging() );
         }
 
         if ( expectDepTrailCheck )
@@ -878,7 +940,7 @@
 
             for ( Iterator iter = checkTooMany.iterator(); iter.hasNext(); )
             {
-                MavenProject project = ( MavenProject ) iter.next();
+                MavenProject project = (MavenProject) iter.next();
 
                 System.out.println( project.getId() );
             }
@@ -895,7 +957,7 @@
 
             for ( Iterator iter = checkTooMany.iterator(); iter.hasNext(); )
             {
-                MavenProject project = ( MavenProject ) iter.next();
+                MavenProject project = (MavenProject) iter.next();
 
                 System.out.println( project.getId() );
             }



Mime
View raw message