@@ -78,6 +78,7 @@ import org.apache.tools.ant.types.EnumeratedAttribute;
*
*
* @author Conor MacNeill
* @author Conor MacNeill
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @author <a href="mailto:j_a_fernandez@yahoo.com">Jose Alberto Fernandez</a>
*
*
* @ant.task category="java"
* @ant.task category="java"
*/
*/
@@ -1027,17 +1028,19 @@ public class Manifest extends Task {
}
}
Manifest toWrite = getDefaultManifest();
Manifest toWrite = getDefaultManifest();
Manifest current = null;
BuildException error = null;
if (mode.getValue().equals("update") && manifestFile.exists()) {
if (manifestFile.exists()) {
FileReader f = null;
FileReader f = null;
try {
try {
f = new FileReader(manifestFile);
f = new FileReader(manifestFile);
toWrite.merge(new Manifest(f) );
current = new Manifest(f );
} catch (ManifestException m) {
} catch (ManifestException m) {
throw new BuildException("Existing manifest " + manifestFile
error = new BuildException("Existing manifest " + manifestFile
+ " is invalid", m, location);
+ " is invalid", m, location);
} catch (IOException e) {
} catch (IOException e) {
throw new BuildException("Failed to read " + manifestFile,
error = new BuildException("Failed to read " + manifestFile,
e, location);
e, location);
} finally {
} finally {
if (f != null) {
if (f != null) {
@@ -1049,11 +1052,25 @@ public class Manifest extends Task {
}
}
try {
try {
if (mode.getValue().equals("update") && manifestFile.exists()) {
if (current != null) {
toWrite.merge(current);
}
else if (error != null) {
throw error;
}
}
toWrite.merge(this);
toWrite.merge(this);
} catch (ManifestException m) {
} catch (ManifestException m) {
throw new BuildException("Manifest is invalid", m, location);
throw new BuildException("Manifest is invalid", m, location);
}
}
if (toWrite.equals(current)) {
log("Manifest has not changed, do not recreate", project.MSG_VERBOSE);
return;
}
PrintWriter w = null;
PrintWriter w = null;
try {
try {
w = new PrintWriter(new FileWriter(manifestFile));
w = new PrintWriter(new FileWriter(manifestFile));