You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by da...@apache.org on 2006/01/25 20:48:31 UTC
svn commit: r372299 - in /maven/plugins/trunk/maven-assembly-plugin: pom.xml
src/main/java/org/apache/maven/plugin/assembly/AbstractAssemblyMojo.java
src/main/mdo/component.mdo src/main/mdo/descriptor.mdo
Author: dantran
Date: Wed Jan 25 11:48:28 2006
New Revision: 372299
URL: http://svn.apache.org/viewcvs?rev=372299&view=rev
Log:
Allow multiple descriptors to share sub-assemblies. MASSEMBLY-62
Added:
maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/component.mdo (with props)
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
maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/descriptor.mdo
Modified: maven/plugins/trunk/maven-assembly-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/pom.xml?rev=372299&r1=372298&r2=372299&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-assembly-plugin/pom.xml Wed Jan 25 11:48:28 2006
@@ -28,18 +28,32 @@
<artifactId>modello-maven-plugin</artifactId>
<executions>
<execution>
+ <id>descriptor</id>
<goals>
<goal>xpp3-reader</goal>
<goal>xpp3-writer</goal>
<goal>java</goal>
<goal>xsd</goal>
</goals>
+ <configuration>
+ <model>src/main/mdo/descriptor.mdo</model>
+ <version>1.0.0</version>
+ </configuration>
+ </execution>
+ <execution>
+ <id>component</id>
+ <goals>
+ <goal>xpp3-reader</goal>
+ <goal>xpp3-writer</goal>
+ <goal>java</goal>
+ <goal>xsd</goal>
+ </goals>
+ <configuration>
+ <model>src/main/mdo/component.mdo</model>
+ <version>1.0.0</version>
+ </configuration>
</execution>
</executions>
- <configuration>
- <model>src/main/mdo/descriptor.mdo</model>
- <version>1.0.0</version>
- </configuration>
</plugin>
</plugins>
</build>
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractAssemblyMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AbstractAssemblyMojo.java?rev=372299&r1=372298&r2=372299&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 Jan 25 11:48:28 2006
@@ -31,7 +31,9 @@
import org.apache.maven.plugins.assembly.model.DependencySet;
import org.apache.maven.plugins.assembly.model.FileItem;
import org.apache.maven.plugins.assembly.model.FileSet;
+import org.apache.maven.plugins.assembly.model.Component;
import org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Reader;
+import org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Reader;
import org.apache.maven.project.MavenProjectHelper;
import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.ArchiverException;
@@ -385,7 +387,7 @@
}
private Assembly getAssembly( Reader reader )
- throws MojoExecutionException
+ throws MojoFailureException, MojoExecutionException
{
Assembly assembly;
try
@@ -411,16 +413,127 @@
includeSiteInAssembly( assembly );
}
+ appendComponentsToMainAssembly( assembly );
+
return assembly;
}
/**
- * Processes Dependency Sets
- *
- * @param archiver
- * @param dependencySets
- * @param includeBaseDirectory
+ * Add the contents of all included components to main assembly
+ * @param assembly
+ * @throws MojoFailureException
+ * @throws MojoExecutionException
+ */
+ private void appendComponentsToMainAssembly( Assembly assembly )
+ throws MojoFailureException, MojoExecutionException
+ {
+ List componentDescriptorFiles = assembly.getComponentDescriptors();
+
+ for( int i = 0 ; i < componentDescriptorFiles.size(); ++i )
+ {
+ Component component = getComponent( componentDescriptorFiles.get( i ).toString() );
+
+ appendComponent( assembly, component );
+ }
+ }
+
+ /**
+ * Add the content of a single Component to main assembly
+ * @param assembly
+ * @param component
+ * @throws MojoFailureException
+ * @throws MojoExecutionException
+ */
+ private void appendComponent( Assembly assembly, Component component )
+ throws MojoFailureException, MojoExecutionException
+ {
+ List dependencySetList = component.getDependencySets();
+
+ for ( int i = 0 ; i < dependencySetList.size(); ++i )
+ {
+ assembly.addDependencySet( (DependencySet) dependencySetList.get(i) );
+ }
+
+ List fileSetList = component.getFileSets();
+
+ for ( int i = 0 ; i < fileSetList.size(); ++i )
+ {
+ assembly.addFileSet( (FileSet) fileSetList.get(i) );
+ }
+
+ List fileList = component.getFiles();
+
+ for ( int i = 0 ; i < fileList.size(); ++i )
+ {
+ assembly.addFile( (FileItem) fileList.get(i) );
+ }
+ }
+
+ /**
+ * Load the Component via a given file path relative to ${basedir}
+ * @param filePath
+ * @return
+ * @throws MojoFailureException
+ * @throws MojoExecutionException
*/
+
+ private Component getComponent( String filePath )
+ throws MojoFailureException, MojoExecutionException
+ {
+ File componentDescriptor = new File ( this.project.getBasedir() + "/" + filePath );
+
+ Reader r;
+ try
+ {
+ r = new FileReader( componentDescriptor );
+ }
+ catch ( FileNotFoundException e )
+ {
+ throw new MojoFailureException( "Unable to find descriptor: " + e.getMessage() );
+ }
+
+ return getComponent( r );
+
+ }
+
+ /**
+ * Load the Component via a Reader
+ * @param reader
+ * @return
+ * @throws MojoExecutionException
+ */
+ private Component getComponent( Reader reader )
+ throws MojoExecutionException
+ {
+ Component component;
+ try
+ {
+ ComponentXpp3Reader r = new ComponentXpp3Reader();
+ component = r.read( reader );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Error reading component descriptor", e );
+ }
+ catch ( XmlPullParserException e )
+ {
+ throw new MojoExecutionException( "Error reading component descriptor", e );
+ }
+ finally
+ {
+ IOUtil.close( reader );
+ }
+
+ return component;
+ }
+
+ /**
+ * Processes Dependency Sets
+ *
+ * @param archiver
+ * @param dependencySets
+ * @param includeBaseDirectory
+ */
protected void processDependencySets( Archiver archiver, List dependencySets, boolean includeBaseDirectory )
throws ArchiverException, IOException, MojoExecutionException, MojoFailureException, XmlPullParserException
{
Added: maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/component.mdo
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/component.mdo?rev=372299&view=auto
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/component.mdo (added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/component.mdo Wed Jan 25 11:48:28 2006
@@ -0,0 +1,294 @@
+<?xml version="1.0"?>
+
+<!-- Note Definitions of FileSet, FileItem, and DependencySet are
+ already defined in descriptor.mod, but repeated here since
+ Modello currently does not have capability to share files
+-->
+<model>
+ <id>component</id>
+ <name>Component</name>
+ <description>
+ <![CDATA[
+ <p>
+ Component contains FileSets, FileItems, and DependencySets already
+ define in Assembly. It allows multiple assemblies to share a set of user
+ defined collections.
+ </p>
+ ]]>
+ </description>
+ <defaults>
+ <default>
+ <key>package</key>
+ <value>org.apache.maven.plugins.assembly.model</value>
+ </default>
+ </defaults>
+ <classes>
+ <class rootElement="true" xml.tagName="component">
+ <name>Component</name>
+ <description>Describes the component layout and packaging.</description>
+ <version>1.0.0</version>
+ <fields>
+ <field>
+ <name>fileSets</name>
+ <version>1.0.0</version>
+ <association>
+ <type>FileSet</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ <description>
+ Specify assembly parameters for groups of files.
+ </description>
+ </field>
+ <field>
+ <name>files</name>
+ <version>1.0.0</version>
+ <association>
+ <type>FileItem</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ <description>
+ Specify assembly parameters for single files.
+ </description>
+ </field>
+ <field>
+ <name>dependencySets</name>
+ <version>1.0.0</version>
+ <association>
+ <type>DependencySet</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ <description>
+ Specify assembly behavior for sets of dependencies.
+ </description>
+ </field>
+ </fields>
+ </class>
+
+ <class>
+ <name>SetBase</name>
+ <version>1.0.0</version>
+ <fields>
+ <field>
+ <name>outputDirectory</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>
+ Specifies the output directory relative to the root
+ of the root directory of the assembly. For example,
+ "log" will put the specified files in the log directory.
+ </description>
+ </field>
+ <field>
+ <name>includes</name>
+ <version>1.0.0</version>
+ <association>
+ <type>String</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ <description>
+ <![CDATA[
+ When <include> subelements are present, they define
+ a set of files and directory to include.
+ ]]>
+ </description>
+ </field>
+ <field>
+ <name>excludes</name>
+ <version>1.0.0</version>
+ <association>
+ <type>String</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ <description>
+ <![CDATA[
+ When <exclude> subelements are present, they define
+ a set of files and directory to exclude.
+ ]]>
+ </description>
+ </field>
+ <field>
+ <name>fileMode</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <defaultValue>0644</defaultValue>
+ <description>
+ <![CDATA[
+ Similar to a UNIX permission. Format: (User)(Group)(Other) where each
+ component is a sum of Read = 4, Write = 2, and Execute = 1. For example,
+ the default value of 0644 translates to User read-write, Group and Other
+ read-only.
+ <a href="http://www.onlamp.com/pub/a/bsd/2000/09/06/FreeBSD_Basics.html">(more on unix-style permissions)</a>
+ ]]>
+ </description>
+ </field>
+ <field>
+ <name>directoryMode</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <defaultValue>0755</defaultValue>
+ <description>
+ <![CDATA[
+ Similar to a UNIX permission. Format: (User)(Group)(Other) where each
+ component is a sum of Read = 4, Write = 2, and Execute = 1. For example,
+ the default value of 0644 translates to User read-write, Group and Other
+ read-only.
+ <a href="http://www.onlamp.com/pub/a/bsd/2000/09/06/FreeBSD_Basics.html">(more on unix-style permissions)</a>
+ ]]>
+ </description>
+ </field>
+ </fields>
+ </class>
+ <class>
+ <name>FileSet</name>
+ <version>1.0.0</version>
+ <superClass>SetBase</superClass>
+ <fields>
+ <field>
+ <name>directory</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>
+ Absolute or relative from the module's directory. For
+ example, "src/main/bin" would select this subdirectory
+ of the project in which this dependency is defined.
+ </description>
+ <required>true</required>
+ </field>
+ <field>
+ <name>lineEnding</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>
+ <![CDATA[
+ Controls the line-endings of files in this fileSet.
+ Valid values:
+ <ul>
+ <li><b>"keep"</b> - Preserve all line endings</li>
+ <li><b>"unix"</b> - Use Unix-style line endings</li>
+ <li><b>"lf"</b> - Use a single line-feed line endings</li>
+ <li><b>"dos"</b> - Use DOS-style line endings</li>
+ <li><b>"crlf"</b> - Use Carraige-return, line-feed line endings</li>
+ </ul>
+ ]]>
+ </description>
+ </field>
+ </fields>
+ </class>
+ <class>
+ <name>FileItem</name>
+ <version>1.0.0</version>
+ <description>
+ Allows individual file copy with option to change destination
+ file name not supported by fileSet
+ </description>
+ <fields>
+ <field>
+ <name>source</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <required>true</required>
+ <description>
+ Absolute or relative from the module's directory.
+ </description>
+ </field>
+ <field>
+ <name>outputDirectory</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <required>false</required>
+ <description>
+ Specifies the output directory relative to the root
+ of the root directory of the assembly. For example,
+ "log" will put the specified files in the log directory.
+ </description>
+ </field>
+ <field>
+ <name>destName</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>
+ Destination file name in outputDirectory.
+ Default is the same name as the source's file.
+ </description>
+ </field>
+ <field>
+ <name>fileMode</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <defaultValue>0644</defaultValue>
+ <description>
+ <![CDATA[
+ Similar to a UNIX permission. Format: (User)(Group)(Other) where each
+ component is a sum of Read = 4, Write = 2, and Execute = 1. For example,
+ the default value of 0644 translates to User read-write, Group and Other
+ read-only.
+ <a href="http://www.onlamp.com/pub/a/bsd/2000/09/06/FreeBSD_Basics.html">(more on unix-style permissions)</a>
+ ]]>
+ </description>
+ </field>
+ <field>
+ <name>lineEnding</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>
+ <![CDATA[
+ Controls the line-endings of files in this fileSet.
+ Valid values are:
+ <ul>
+ <li><b>"keep"</b> - Preserve all line endings</li>
+ <li><b>"unix"</b> - Use Unix-style line endings</li>
+ <li><b>"lf"</b> - Use a single line-feed line endings</li>
+ <li><b>"dos"</b> - Use DOS-style line endings</li>
+ <li><b>"crlf"</b> - Use Carraige-return, line-feed line endings</li>
+ </ul>
+ ]]>
+ </description>
+ </field>
+ </fields>
+ </class>
+
+ <class>
+ <name>DependencySet</name>
+ <version>1.0.0</version>
+ <superClass>SetBase</superClass>
+ <description>Defines a dependency set</description>
+ <fields>
+ <field>
+ <name>outputFileNameMapping</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <defaultValue>${artifactId}-${version}.${extension}</defaultValue>
+ <description>
+ Specify the mapping pattern for all dependencies included
+ in this assembly.
+ Default is ${artifactId}-${version}.${extension}.
+ </description>
+ </field>
+ <field>
+ <name>unpack</name>
+ <type>boolean</type>
+ <defaultValue>false</defaultValue>
+ <description>
+ If set to true, this property will unpack all dependencies
+ into the specified output directory. When set to false
+ dependencies will be includes as archives (jars).
+ Default value is false.
+ </description>
+ </field>
+ <field>
+ <name>scope</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <defaultValue>runtime</defaultValue>
+ <required>true</required>
+ <description>
+ Specifies the dependency scope for this dependencySet.
+ Default scope value is "runtime".
+ </description>
+ </field>
+ </fields>
+ </class>
+
+ </classes>
+</model>
+
Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/component.mdo
------------------------------------------------------------------------------
svn:executable = *
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/descriptor.mdo
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/descriptor.mdo?rev=372299&r1=372298&r2=372299&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/descriptor.mdo (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/descriptor.mdo Wed Jan 25 11:48:28 2006
@@ -1,5 +1,13 @@
<?xml version="1.0"?>
+<!--
+ Since modello does not have the capability to share descriptor,
+ If you make changes to FileSet, FileItem, DependendencySet, or
+ adding new collection, make sure to propagate your changes
+ to "component.xml".
+-->
+
+
<model>
<id>assembly</id>
<name>Assembly</name>
@@ -116,8 +124,24 @@
Specify assembly behavior for sets of dependencies.
</description>
</field>
+
+ <field>
+ <name>componentDescriptors</name>
+ <version>1.0.0</version>
+ <association>
+ <type>String</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ <description>
+ File relative to basedir containing Component.
+ </description>
+ </field>
+
+
</fields>
</class>
+
+
<class>
<name>SetBase</name>
<version>1.0.0</version>
@@ -342,6 +366,7 @@
</field>
</fields>
</class>
+
</classes>
</model>