bodewig 2002/10/04 05:43:46
Modified: . WHATSNEW
src/etc/testcases/taskdefs manifest.xml
src/main/org/apache/tools/ant/taskdefs Manifest.java
src/testcases/org/apache/tools/ant/taskdefs
ManifestTest.java
Log:
<manifest> could miss situations in which an update was necessary.
PR: 12440
Submitted by: Thomas Zimber <tzimber at e2e.ch>
Revision Changes Path
1.299 +3 -0 jakarta-ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
retrieving revision 1.298
retrieving revision 1.299
diff -u -r1.298 -r1.299
--- WHATSNEW 4 Oct 2002 11:59:48 -0000 1.298
+++ WHATSNEW 4 Oct 2002 12:43:46 -0000 1.299
@@ -19,6 +19,9 @@
* <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:
--------------
1.7 +12 -0 jakarta-ant/src/etc/testcases/taskdefs/manifest.xml
Index: manifest.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/manifest.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- manifest.xml 1 Jun 2002 12:26:36 -0000 1.6
+++ manifest.xml 4 Oct 2002 12:43:46 -0000 1.7
@@ -188,6 +188,18 @@
<manifest file="mftest.mf" mode="update">
<attribute name="Foo" value="Bar" />
</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 name="clean">
1.37 +20 -2
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java
Index: Manifest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- Manifest.java 25 Jul 2002 15:21:05 -0000 1.36
+++ Manifest.java 4 Oct 2002 12:43:46 -0000 1.37
@@ -626,6 +626,24 @@
}
/**
+ * 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.
*
* @param attribute the attribute to be stored
@@ -841,7 +859,7 @@
throws ManifestException {
if (other != null) {
if (overwriteMain) {
- mainSection = other.mainSection;
+ mainSection = (Section) other.mainSection.clone();
} else {
mainSection.merge(other.mainSection);
}
@@ -858,7 +876,7 @@
= (Section) other.sections.get(sectionName);
if (ourSection == null) {
if (otherSection != null) {
- addConfiguredSection(otherSection);
+ addConfiguredSection((Section)
otherSection.clone());
}
} else {
ourSection.merge(otherSection);
1.8 +7 -0
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ManifestTest.java
Index: ManifestTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ManifestTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ManifestTest.java 20 Mar 2002 12:11:57 -0000 1.7
+++ ManifestTest.java 4 Oct 2002 12:43:46 -0000 1.8
@@ -315,6 +315,13 @@
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);
}
/**
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>