PR: 12440 Submitted by: Thomas Zimber <tzimber at e2e.ch> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273405 13f79535-47bb-0310-9956-ffa450edef68master
@@ -19,6 +19,9 @@ Fixed bugs: | |||||
* <property environment=... /> now works on OS/400. | * <property environment=... /> now works on OS/400. | ||||
* <manifest> wouldn't update an existing manifest if only an attribute | |||||
of an existing section changed. | |||||
Other changes: | Other changes: | ||||
-------------- | -------------- | ||||
@@ -188,6 +188,18 @@ | |||||
<manifest file="mftest.mf" mode="update"> | <manifest file="mftest.mf" mode="update"> | ||||
<attribute name="Foo" value="Bar" /> | <attribute name="Foo" value="Bar" /> | ||||
</manifest> | </manifest> | ||||
<copy file="manifests/test2.mf" toFile="mftest2.mf" /> | |||||
<manifest file="mftest2.mf" mode="update"> | |||||
<section name="Test"> | |||||
<attribute name="Foo" value="Bar" /> | |||||
</section> | |||||
</manifest> | |||||
<manifest file="mftest2.mf" mode="update"> | |||||
<section name="Test"> | |||||
<attribute name="Foo" value="Baz" /> | |||||
</section> | |||||
</manifest> | |||||
</target> | </target> | ||||
<target name="clean"> | <target name="clean"> | ||||
@@ -625,6 +625,24 @@ public class Manifest { | |||||
return null; | 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. | * Store an attribute and update the index. | ||||
* | * | ||||
@@ -841,7 +859,7 @@ public class Manifest { | |||||
throws ManifestException { | throws ManifestException { | ||||
if (other != null) { | if (other != null) { | ||||
if (overwriteMain) { | if (overwriteMain) { | ||||
mainSection = other.mainSection; | |||||
mainSection = (Section) other.mainSection.clone(); | |||||
} else { | } else { | ||||
mainSection.merge(other.mainSection); | mainSection.merge(other.mainSection); | ||||
} | } | ||||
@@ -858,7 +876,7 @@ public class Manifest { | |||||
= (Section) other.sections.get(sectionName); | = (Section) other.sections.get(sectionName); | ||||
if (ourSection == null) { | if (ourSection == null) { | ||||
if (otherSection != null) { | if (otherSection != null) { | ||||
addConfiguredSection(otherSection); | |||||
addConfiguredSection((Section) otherSection.clone()); | |||||
} | } | ||||
} else { | } else { | ||||
ourSection.merge(otherSection); | ourSection.merge(otherSection); | ||||
@@ -315,6 +315,13 @@ public class ManifestTest extends BuildFileTest { | |||||
assertNotNull(mfAsString); | assertNotNull(mfAsString); | ||||
assertTrue(mfAsString.startsWith("Manifest-Version: 2.0")); | assertTrue(mfAsString.startsWith("Manifest-Version: 2.0")); | ||||
assertTrue(mfAsString.indexOf("Foo: Bar") > -1); | 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); | |||||
} | } | ||||
/** | /** | ||||