Browse Source

Make it possible to create manifest only jars with the option duplicate="preserve"

PR: 32802


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277264 13f79535-47bb-0310-9956-ffa450edef68
master
Antoine Levy-Lambert 20 years ago
parent
commit
6e72941062
6 changed files with 33 additions and 1 deletions
  1. +2
    -0
      WHATSNEW
  2. +12
    -0
      src/etc/testcases/taskdefs/jar.xml
  3. +5
    -0
      src/etc/testcases/taskdefs/zip.xml
  4. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  5. +5
    -0
      src/testcases/org/apache/tools/ant/taskdefs/JarTest.java
  6. +6
    -0
      src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java

+ 2
- 0
WHATSNEW View File

@@ -176,6 +176,8 @@ Fixed bugs:

* Zip task was not zipping when only empty directories were found. Bugzilla 30365.

* Jar task was not including manifest files when duplicate="preserve" was chosen. Bugzilla 32802.

* Classpath was treated in the same way as -lib options. Bugzilla 28046.

* Manual page for cvsversion contained incorrect attributes and did not say since 1.6.1.


+ 12
- 0
src/etc/testcases/taskdefs/jar.xml View File

@@ -209,5 +209,17 @@
<mkdir dir="${tmp.dir}/sub"/>
<touch file="${tmp.dir}/sub/foo"/>
<jar destfile="${tmp.jar}" index="yes" basedir="${tmp.dir}"/>
</target>
<!-- bug 32802 -->
<target name="testManifestOnlyJar">
<mkdir dir="${tmp.dir}"/>
<jar destfile="${tmp.jar}" duplicate="preserve">
<manifest>
<attribute name="Foo" value="bar"/>
</manifest>
</jar>
<mkdir dir="${tmp.dir}"/>
<unzip src="${tmp.jar}" dest="${tmp.dir}"/>

</target>
</project>

+ 5
- 0
src/etc/testcases/taskdefs/zip.xml View File

@@ -134,6 +134,11 @@
<zip destfile="test3.zip" basedir="empty" update="true"/>
</target>

<target name="zipEmptyCreate">
<mkdir dir="empty"/>
<zip destfile="test3.zip" basedir="empty" whenempty="create" includes="*.xyz"/>
</target>

<target name="cleanup">
<delete file="test3.zip"/>
<delete file="test4.zip"/>


+ 3
- 1
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -800,7 +800,9 @@ public class Zip extends MatchingTask {
getLocation());
} else {
// Create.
createEmptyZip(zipFile);
if (!zipFile.exists()) {
needsUpdate = true;
}
}
return new ArchiveState(needsUpdate, initialResources);
}


+ 5
- 0
src/testcases/org/apache/tools/ant/taskdefs/JarTest.java View File

@@ -256,4 +256,9 @@ public class JarTest extends BuildFileTest {
}
}
}
public void testManifestOnlyJar() {
executeTarget("testManifestOnlyJar");
File manifestFile = getProject().resolveFile(tempDir + "META-INF" + File.separator + "MANIFEST.MF");
assertTrue(manifestFile.exists());
}
}

+ 6
- 0
src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java View File

@@ -139,4 +139,10 @@ public class ZipTest extends BuildFileTest {
assertTrue("archive should be created",
getProject().resolveFile("test3.zip").exists());
}
public void testZipEmptyCreate() {
executeTarget("zipEmptyCreate");
assertTrue("archive should be created",
getProject().resolveFile("test3.zip").exists());

}
}

Loading…
Cancel
Save