ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1555355 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/taskdefs/Jar.java src/tests/antunit/taskdefs/jar-test.xml
Date Sat, 04 Jan 2014 15:25:05 GMT
Author: bodewig
Date: Sat Jan  4 15:25:04 2014
New Revision: 1555355

URL: http://svn.apache.org/r1555355
Log:
merge filesetmanifest=mergewithoutmain even if no explicit manifest has been specified.  PR
54171

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=1555355&r1=1555354&r2=1555355&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Sat Jan  4 15:25:04 2014
@@ -56,6 +56,11 @@ Fixed bugs:
  * <javadoc> caused a NullPointerException when no destdir was set.
    Bugzilla Report 55949
 
+ * <jar filesetmanifest="mergewithoutmain"> would still include the
+   Main section of the fileset manifests if there was no nested
+   manifest or manifest attribute.
+   Bugzilla Report 54171
+
 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=1555355&r1=1555354&r2=1555355&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 Jan  4 15:25:04 2014
@@ -516,8 +516,6 @@ public class Jar extends Zip {
     private Manifest createManifest()
         throws BuildException {
         try {
-            Manifest finalManifest = Manifest.getDefaultManifest();
-
             if (manifest == null) {
                 if (manifestFile != null) {
                     // if we haven't got the manifest yet, attempt to
@@ -526,6 +524,25 @@ public class Jar extends Zip {
                 }
             }
 
+            // fileset manifest must come even before the default
+            // manifest if mergewithoutmain is selected and there is
+            // no explicit manifest specified - otherwise the Main
+            // section of the fileset manifest is still merged to the
+            // final manifest.
+            boolean mergeFileSetFirst = !mergeManifestsMain
+                && filesetManifest != null
+                && configuredManifest == null && manifest == null;
+
+            Manifest finalManifest;
+            if (mergeFileSetFirst) {
+                finalManifest = new Manifest();
+                finalManifest.merge(filesetManifest, false, mergeClassPaths);
+                finalManifest.merge(Manifest.getDefaultManifest(),
+                                    true, mergeClassPaths);
+            } else {
+                finalManifest = Manifest.getDefaultManifest();
+            }
+
             /*
              * Precedence: manifestFile wins over inline manifest,
              * over manifests read from the filesets over the original
@@ -537,7 +554,9 @@ public class Jar extends Zip {
             if (isInUpdateMode()) {
                 finalManifest.merge(originalManifest, false, mergeClassPaths);
             }
-            finalManifest.merge(filesetManifest, false, mergeClassPaths);
+            if (!mergeFileSetFirst) {
+                finalManifest.merge(filesetManifest, false, mergeClassPaths);
+            }
             finalManifest.merge(configuredManifest, !mergeManifestsMain,
                                 mergeClassPaths);
             finalManifest.merge(manifest, !mergeManifestsMain,

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=1555355&r1=1555354&r2=1555355&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/jar-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/jar-test.xml Sat Jan  4 15:25:04 2014
@@ -226,4 +226,27 @@ Main-Class: MyClass
                                resource="${output}/META-INF/MANIFEST.MF"/>
   </target>
 
+  <target name="testMergeWithoutMainWithoutExplicitManifest"
+          description="https://issues.apache.org/bugzilla/show_bug.cgi?id=54171">
+    <mkdir dir="${input}"/>
+    <mkdir dir="${output}"/>
+    <jar destfile="${input}/input.jar">
+      <manifest>
+        <attribute name="Foo" value="Main Section"/>
+      </manifest>
+      <fileset dir="."/>
+    </jar>
+    <jar destfile="${input}/test.jar"
+         filesetmanifest="mergewithoutmain">
+      <zipgroupfileset dir="${input}">
+        <include name="input.jar"/>
+      </zipgroupfileset>
+    </jar>
+    <unjar src="${input}/test.jar" dest="${output}"/>
+    <au:assertFileExists file="${output}/META-INF/MANIFEST.MF"/>
+    <au:assertResourceDoesntContain
+        value="Foo: Main Section"
+        resource="${output}/META-INF/MANIFEST.MF"/>
+  </target>
+
 </project>



Mime
View raw message