Browse Source

Don't rewrite the manifest if it hasn't changed.

PR:	7045
Submitted by:	j_a_fernandez@yahoo.com (Jose Alberto Fernandez)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271920 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 23 years ago
parent
commit
d1392f7d25
1 changed files with 21 additions and 4 deletions
  1. +21
    -4
      src/main/org/apache/tools/ant/taskdefs/Manifest.java

+ 21
- 4
src/main/org/apache/tools/ant/taskdefs/Manifest.java View File

@@ -78,6 +78,7 @@ import org.apache.tools.ant.types.EnumeratedAttribute;
*
* @author Conor MacNeill
* @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"
*/
@@ -1027,17 +1028,19 @@ public class Manifest extends Task {
}

Manifest toWrite = getDefaultManifest();
Manifest current = null;
BuildException error = null;

if (mode.getValue().equals("update") && manifestFile.exists()) {
if (manifestFile.exists()) {
FileReader f = null;
try {
f = new FileReader(manifestFile);
toWrite.merge(new Manifest(f));
current = new Manifest(f);
} catch (ManifestException m) {
throw new BuildException("Existing manifest " + manifestFile
error = new BuildException("Existing manifest " + manifestFile
+ " is invalid", m, location);
} catch (IOException e) {
throw new BuildException("Failed to read " + manifestFile,
error = new BuildException("Failed to read " + manifestFile,
e, location);
} finally {
if (f != null) {
@@ -1049,11 +1052,25 @@ public class Manifest extends Task {
}

try {
if (mode.getValue().equals("update") && manifestFile.exists()) {
if (current != null) {
toWrite.merge(current);
}
else if (error != null) {
throw error;
}
}

toWrite.merge(this);
} catch (ManifestException m) {
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;
try {
w = new PrintWriter(new FileWriter(manifestFile));


Loading…
Cancel
Save