diff --git a/WHATSNEW b/WHATSNEW
index d2618c8d7..b66f15f81 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -19,6 +19,9 @@ Fixed bugs:
* now works on OS/400.
+* wouldn't update an existing manifest if only an attribute
+ of an existing section changed.
+
Other changes:
--------------
diff --git a/src/etc/testcases/taskdefs/manifest.xml b/src/etc/testcases/taskdefs/manifest.xml
index 5d5933dba..4c86fcada 100644
--- a/src/etc/testcases/taskdefs/manifest.xml
+++ b/src/etc/testcases/taskdefs/manifest.xml
@@ -188,6 +188,18 @@
+
+
+
+
+
+
+
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/Manifest.java b/src/main/org/apache/tools/ant/taskdefs/Manifest.java
index 97731c722..c091a0816 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Manifest.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Manifest.java
@@ -625,6 +625,24 @@ public class Manifest {
return null;
}
+ /**
+ * Clone this section
+ *
+ * @since Ant 1.5.2
+ */
+ public Object clone() {
+ Section cloned = new Section();
+ cloned.setName(name);
+ Enumeration e = getAttributeKeys();
+ while (e.hasMoreElements()) {
+ String key = (String) e.nextElement();
+ Attribute attribute = getAttribute(key);
+ cloned.storeAttribute(new Attribute(attribute.getName(),
+ attribute.getValue()));
+ }
+ return cloned;
+ }
+
/**
* Store an attribute and update the index.
*
@@ -841,7 +859,7 @@ public class Manifest {
throws ManifestException {
if (other != null) {
if (overwriteMain) {
- mainSection = other.mainSection;
+ mainSection = (Section) other.mainSection.clone();
} else {
mainSection.merge(other.mainSection);
}
@@ -858,7 +876,7 @@ public class Manifest {
= (Section) other.sections.get(sectionName);
if (ourSection == null) {
if (otherSection != null) {
- addConfiguredSection(otherSection);
+ addConfiguredSection((Section) otherSection.clone());
}
} else {
ourSection.merge(otherSection);
diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ManifestTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ManifestTest.java
index 24c7a7925..7c04c7853 100644
--- a/src/testcases/org/apache/tools/ant/taskdefs/ManifestTest.java
+++ b/src/testcases/org/apache/tools/ant/taskdefs/ManifestTest.java
@@ -315,6 +315,13 @@ public class ManifestTest extends BuildFileTest {
assertNotNull(mfAsString);
assertTrue(mfAsString.startsWith("Manifest-Version: 2.0"));
assertTrue(mfAsString.indexOf("Foo: Bar") > -1);
+
+ mf = getManifest("src/etc/testcases/taskdefs/mftest2.mf");
+ assertNotNull(mf);
+ mfAsString = mf.toString();
+ assertNotNull(mfAsString);
+ assertEquals(-1, mfAsString.indexOf("Foo: Bar"));
+ assertTrue(mfAsString.indexOf("Foo: Baz") > -1);
}
/**