maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r585558 - in /maven/plugins/trunk/maven-assembly-plugin/src: main/java/org/apache/maven/plugin/assembly/io/ main/java/org/apache/maven/plugin/assembly/mojos/ main/mdo/ test/java/org/apache/maven/plugin/assembly/io/
Date Wed, 17 Oct 2007 16:26:49 GMT
Author: jdcasey
Date: Wed Oct 17 09:26:48 2007
New Revision: 585558

URL: http://svn.apache.org/viewvc?rev=585558&view=rev
Log:
Adding ability to add hooks to handle arbitrary container descriptors, just like the plexus
components.xml file is handled now. Also, adding a skip flag to allow fine-grained control
over any particular execution using a property in the POM (which can be set or overridden
by profile).

Modified:
    maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.java
    maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractAssemblyMojo.java
    maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/component.mdo
    maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.java?rev=585558&r1=585557&r2=585558&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.java
(original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.java
Wed Oct 17 09:26:48 2007
@@ -10,6 +10,7 @@
 import org.apache.maven.plugin.assembly.interpolation.AssemblyInterpolator;
 import org.apache.maven.plugin.assembly.model.Assembly;
 import org.apache.maven.plugin.assembly.model.Component;
+import org.apache.maven.plugin.assembly.model.ContainerDescriptorHandlerConfig;
 import org.apache.maven.plugin.assembly.model.DependencySet;
 import org.apache.maven.plugin.assembly.model.FileItem;
 import org.apache.maven.plugin.assembly.model.FileSet;
@@ -382,6 +383,14 @@
      */
     protected void mergeComponentWithAssembly( Component component, Assembly assembly )
     {
+        List containerHandlerDescriptors = component.getContainerDescriptorHandlers();
+
+        for ( Iterator it = containerHandlerDescriptors.iterator(); it.hasNext(); )
+        {
+            ContainerDescriptorHandlerConfig cfg = (ContainerDescriptorHandlerConfig) it.next();
+            assembly.addContainerDescriptorHandler( cfg );
+        }
+
         List dependencySetList = component.getDependencySets();
 
         for ( Iterator it = dependencySetList.iterator(); it.hasNext(); )

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractAssemblyMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractAssemblyMojo.java?rev=585558&r1=585557&r2=585558&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractAssemblyMojo.java
(original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/mojos/AbstractAssemblyMojo.java
Wed Oct 17 09:26:48 2007
@@ -48,6 +48,15 @@
 {
 
     /**
+     * Flag allowing one or more executions of the assembly plugin to be configured
+     * as skipped for a particular build. This makes the assembly plugin more controllable
+     * from profiles.
+     *
+     * @parameter default-value="false"
+     */
+    private boolean skipAssembly;
+
+    /**
      * If this flag is set, everything up to the call to Archiver.createArchive() will be
executed.
      *
      * @parameter expression="${assembly.dryRun}" default-value="false"
@@ -266,6 +275,12 @@
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
+        if ( skipAssembly )
+        {
+            getLog().info( "Assemblies have been skipped per configuration of the skipAssembly
parameter." );
+            return;
+        }
+
         List assemblies;
         try
         {

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/component.mdo
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/component.mdo?rev=585558&r1=585557&r2=585558&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/component.mdo (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/component.mdo Wed Oct 17 09:26:48
2007
@@ -112,6 +112,20 @@
             ]]>
           </description>
         </field>
+        <field>
+          <name>containerDescriptorHandlers</name>
+          <version>1.1.0</version>
+          <association>
+            <type>ContainerDescriptorHandlerConfig</type>
+            <multiplicity>*</multiplicity>
+          </association>
+          <description>
+            <![CDATA[
+            Set of components which filter various container descriptors out of
+            the normal archive stream, so they can be aggregated then added.
+            ]]>
+          </description>
+        </field>
       </fields>
     </class>
 
@@ -558,6 +572,36 @@
           <defaultValue>false</defaultValue>
           <type>boolean</type>
         </field>
+      </fields>
+    </class>
+    <class>
+      <name>ContainerDescriptorHandlerConfig</name>
+      <version>1.1.0</version>
+      <description>
+        Configures a filter for files headed into the assembly archive, to enable
+        aggregation of various types of descriptor fragments, such as components.xml,
+        web.xml, etc.
+      </description>
+      <fields>
+        <field>
+          <name>handlerName</name>
+          <version>1.1.0</version>
+          <description>
+            The handler's plexus role-hint, for lookup from the container.
+          </description>
+          <type>String</type>
+          <required>true</required>
+        </field>
+        <!-- Commented out until it can be implemented and tested...
+        <field>
+          <name>configuration</name>
+          <version>1.1.0</version>
+          <description>
+            Configuration options for the handler.
+          </description>
+          <type>DOM</type>
+        </field>
+         -->
       </fields>
     </class>
   </classes>

Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java?rev=585558&r1=585557&r2=585558&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java
(original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java
Wed Oct 17 09:26:48 2007
@@ -7,6 +7,7 @@
 import org.apache.maven.plugin.assembly.InvalidAssemblerConfigurationException;
 import org.apache.maven.plugin.assembly.model.Assembly;
 import org.apache.maven.plugin.assembly.model.Component;
+import org.apache.maven.plugin.assembly.model.ContainerDescriptorHandlerConfig;
 import org.apache.maven.plugin.assembly.model.DependencySet;
 import org.apache.maven.plugin.assembly.model.FileItem;
 import org.apache.maven.plugin.assembly.model.FileSet;
@@ -342,6 +343,40 @@
         assertEquals( Artifact.SCOPE_RUNTIME, ((Repository) depSets.get( 0 )).getScope()
);
         assertEquals( Artifact.SCOPE_COMPILE, ((Repository) depSets.get( 1 )).getScope()
);
         assertEquals( Artifact.SCOPE_SYSTEM, ((Repository) depSets.get( 2 )).getScope() );
+    }
+
+    public void testMergeComponentWithAssembly_ShouldAddOneContainerDescriptorHandlerToExistingListOfTwo()
+    {
+        Assembly assembly = new Assembly();
+
+        ContainerDescriptorHandlerConfig cfg = new ContainerDescriptorHandlerConfig();
+        cfg.setHandlerName( "one" );
+
+        assembly.addContainerDescriptorHandler( cfg );
+
+        cfg = new ContainerDescriptorHandlerConfig();
+        cfg.setHandlerName( "two" );
+
+        assembly.addContainerDescriptorHandler( cfg );
+
+        Component component = new Component();
+
+        cfg = new ContainerDescriptorHandlerConfig();
+        cfg.setHandlerName( "three" );
+
+        component.addContainerDescriptorHandler( cfg );
+
+        new DefaultAssemblyReader().mergeComponentWithAssembly( component, assembly );
+
+        List result = assembly.getContainerDescriptorHandlers();
+
+        assertNotNull( result );
+        assertEquals( 3, result.size() );
+
+        Iterator it = result.iterator();
+        assertEquals( "one", ((ContainerDescriptorHandlerConfig) it.next()).getHandlerName()
);
+        assertEquals( "two", ((ContainerDescriptorHandlerConfig) it.next()).getHandlerName()
);
+        assertEquals( "three", ((ContainerDescriptorHandlerConfig) it.next()).getHandlerName()
);
     }
 
     // FIXME: Deep merging should take place...



Mime
View raw message