maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dant...@apache.org
Subject svn commit: r358070 - in /maven/plugins/trunk/maven-assembly-plugin/src/main: java/org/apache/maven/plugin/assembly/AbstractAssemblyMojo.java mdo/descriptor.mdo
Date Tue, 20 Dec 2005 18:55:49 GMT
Author: dantran
Date: Tue Dec 20 10:52:17 2005
New Revision: 358070

URL: http://svn.apache.org/viewcvs?rev=358070&view=rev
Log:
MASSEMBLY-17

Modified:
    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/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=358070&r1=358069&r2=358070&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
Tue Dec 20 10:52:17 2005
@@ -20,6 +20,7 @@
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.assembly.model.Assembly;
 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.io.xpp3.AssemblyXpp3Reader;
 import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
@@ -115,6 +116,15 @@
     private File tempRoot;
 
     /**
+     * Temporary file for line ending translation.
+     *
+     * @parameter expression="${project.build.directory}/tempFile"
+     * @required
+     * @readonly
+     */
+    private File tempFile;
+    
+    /**
      * Directory for site generated.
      *
      * @parameter expression="${project.build.directory}/site"
@@ -223,6 +233,7 @@
         File destFile;
         processDependencySets( archiver, assembly.getDependencySets(), assembly.isIncludeBaseDirectory()
);
         processFileSets( archiver, assembly.getFileSets(), assembly.isIncludeBaseDirectory()
);
+        processFileList( archiver, assembly.getFiles(), assembly.isIncludeBaseDirectory()
);
 
         componentsXmlFilter.addToArchive( archiver );
 
@@ -482,6 +493,50 @@
         }
     }
 
+    /**
+     * Copy files to the distribution with option to change destination name
+     *
+     * @param archiver
+     * @param fileList
+     * @throws org.codehaus.plexus.archiver.ArchiverException
+     */
+    protected void processFileList( Archiver archiver, List fileList, boolean includeBaseDirecetory
)
+        throws ArchiverException, IOException
+    {
+        for ( Iterator i = fileList.iterator(); i.hasNext(); )
+        {
+            FileItem fileItem = (FileItem) i.next();
+            
+            File source = new File ( fileItem.getSource() );
+            
+            String outputDirectory = fileItem.getOutputDirectory();
+            
+            if ( outputDirectory == null )
+            {
+            	outputDirectory = "";
+            }
+            
+            String destName = fileItem.getDestName();
+            
+            if  ( destName == null )
+            {
+            	destName = source.getName();
+            }
+
+            String lineEnding = getLineEndingCharacters( fileItem.getLineEnding() );
+            
+            if ( lineEnding != null )
+            {
+            	this.copyReplacingLineEndings( source, this.tempFile, lineEnding );
+            	source = this.tempFile;
+            }
+            
+            outputDirectory = getOutputDirectory( outputDirectory, includeBaseDirecetory
);
+            
+            archiver.addFile( source , outputDirectory + "/" + destName, Integer.parseInt(
fileItem.getFileMode() ) );
+        }
+    }
+    
     /**
      * Evaluates Filename Mapping
      *

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=358070&r1=358069&r2=358070&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 Tue Dec 20 10:52:17
2005
@@ -45,6 +45,15 @@
           </association>
         </field>
         <field>
+          <name>files</name>
+          <version>1.0.0</version>
+          <association>
+            <type>FileItem</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+        
+        <field>
           <name>dependencySets</name>
           <version>1.0.0</version>
           <association>
@@ -113,6 +122,47 @@
         </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>
+          <description>Absolute or relative from the module's directory.</description>
+          <required>true</required>
+        </field>
+        <field>
+          <name>outputDirectory</name>
+          <version>1.0.0</version>
+          <type>String</type>
+          <description>Relative to root archive.</description>
+          <required>false</required>
+        </field>
+        <field>
+          <name>destName</name>
+          <version>1.0.0</version>
+          <type>String</type>
+          <description>Destination file name in outputDirectory. Default is source's
file name</description>
+        </field>
+        <field>
+          <name>fileMode</name>
+          <version>1.0.0</version>
+          <type>String</type>
+          <defaultValue>0644</defaultValue>
+        </field>
+        <field>
+          <name>lineEnding</name>
+          <version>1.0.0</version>
+          <type>String</type>
+          <!-- keep | unix | lf | dos | crlf -->
+        </field>
+      </fields>
+    </class>
+    
     <class>
       <name>DependencySet</name>
       <version>1.0.0</version>



Mime
View raw message