ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r983308 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/taskdefs/Jar.java src/tests/antunit/taskdefs/jar-test.xml
Date Sat, 07 Aug 2010 20:43:21 GMT
Author: bodewig
Date: Sat Aug  7 20:43:21 2010
New Revision: 983308

URL: http://svn.apache.org/viewvc?rev=983308&view=rev
Log:
<jar doesn't merge manifests that come from zipfilesets with prefix.  PR 49605

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Jar.java
    ant/core/trunk/src/tests/antunit/taskdefs/jar-test.xml

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=983308&r1=983307&r2=983308&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Sat Aug  7 20:43:21 2010
@@ -115,6 +115,10 @@ Fixed bugs:
    files matched.
    Bugzilla Report 49594.
 
+ * <jar filesetmanifest="merge"> didn't work for manifests added via
+   <zipfileset>s that used the prefix or fullpath attributes.
+   Bugzilla Report 49605.
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Jar.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Jar.java?rev=983308&r1=983307&r2=983308&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Jar.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Jar.java Sat Aug  7 20:43:21 2010
@@ -46,6 +46,7 @@ import java.util.zip.ZipFile;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Manifest.Section;
+import org.apache.tools.ant.types.ArchiveFileSet;
 import org.apache.tools.ant.types.EnumeratedAttribute;
 import org.apache.tools.ant.types.FileSet;
 import org.apache.tools.ant.types.Path;
@@ -1176,6 +1177,18 @@ public class Jar extends Zip {
             }
             for (int j = 0; j < resources[0].length; j++) {
                 String name = resources[0][j].getName().replace('\\', '/');
+                if (rcs[i] instanceof ArchiveFileSet) {
+                    ArchiveFileSet afs = (ArchiveFileSet) rcs[i];
+                    if (!"".equals(afs.getFullpath(getProject()))) {
+                        name = afs.getFullpath(getProject());
+                    } else if (!"".equals(afs.getPrefix(getProject()))) {
+                        String prefix = afs.getPrefix(getProject());
+                        if (!prefix.endsWith("/") && !prefix.endsWith("\\")) {
+                            prefix += "/";
+                        }
+                        name = prefix + name;
+                    }
+                }
                 if (name.equalsIgnoreCase(MANIFEST_NAME)) {
                     manifests[i] = new Resource[] {resources[0][j]};
                     break;

Modified: ant/core/trunk/src/tests/antunit/taskdefs/jar-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/jar-test.xml?rev=983308&r1=983307&r2=983308&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/jar-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/jar-test.xml Sat Aug  7 20:43:21 2010
@@ -207,4 +207,23 @@
     <au:assertResourceContains value="Test: Header"
                                resource="${output}/META-INF/MANIFEST.MF"/>
   </target>
+
+  <target name="testZipfilesetMerge"
+          description="https://issues.apache.org/bugzilla/show_bug.cgi?id=49605">
+    <mkdir dir="${input}"/>
+    <mkdir dir="${output}"/>
+    <echo file="${input}/MANIFEST.MF">Manifest-Version: 1.0
+Main-Class: MyClass
+
+</echo>
+    <jar destfile="${input}/manifesttest.jar"
+         filesetmanifest="merge">
+      <zipfileset file="${input}/MANIFEST.MF" prefix="META-INF"/>
+    </jar>
+    <unjar src="${input}/manifesttest.jar" dest="${output}"/>
+    <au:assertFileExists file="${output}/META-INF/MANIFEST.MF"/>
+    <au:assertResourceContains value="Main-Class: MyClass"
+                               resource="${output}/META-INF/MANIFEST.MF"/>
+  </target>
+
 </project>



Mime
View raw message