Browse Source

don't rebuild zip/jar files if they are up to date already

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267605 13f79535-47bb-0310-9956-ffa450edef68
master
Sam Ruby 25 years ago
parent
commit
e0ad7527a0
1 changed files with 10 additions and 2 deletions
  1. +10
    -2
      src/main/org/apache/tools/ant/taskdefs/Zip.java

+ 10
- 2
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -92,8 +92,6 @@ public class Zip extends MatchingTask {
}

public void execute() throws BuildException {
project.log("Building "+ archiveType +": "+ zipFile.getAbsolutePath());

if (baseDir == null) {
throw new BuildException("basedir attribute must be set!");
}
@@ -106,6 +104,16 @@ public class Zip extends MatchingTask {
String[] files = ds.getIncludedFiles();
String[] dirs = ds.getIncludedDirectories();

// quick exit if the target is up to date
boolean upToDate = true;
for (int i=0; i<files.length && upToDate; i++)
if (new File(baseDir,files[i]).lastModified() >
zipFile.lastModified())
upToDate = false;
if (upToDate) return;

project.log("Building "+ archiveType +": "+ zipFile.getAbsolutePath());

try {
ZipOutputStream zOut = new ZipOutputStream(new FileOutputStream(zipFile));
initZipOutputStream(zOut);


Loading…
Cancel
Save