Browse Source

Javadoc & cosmetics

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277516 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 20 years ago
parent
commit
a7ce003c13
1 changed files with 14 additions and 32 deletions
  1. +14
    -32
      src/main/org/apache/tools/ant/taskdefs/DependSet.java

+ 14
- 32
src/main/org/apache/tools/ant/taskdefs/DependSet.java View File

@@ -92,6 +92,7 @@ public class DependSet extends MatchingTask {


/** /**
* Add a set of source files. * Add a set of source files.
* @param fs the FileSet to add.
*/ */
public void addSrcfileset(FileSet fs) { public void addSrcfileset(FileSet fs) {
sourceFileSets.addElement(fs); sourceFileSets.addElement(fs);
@@ -99,6 +100,7 @@ public class DependSet extends MatchingTask {


/** /**
* Add a list of source files. * Add a list of source files.
* @param fl the FileList to add.
*/ */
public void addSrcfilelist(FileList fl) { public void addSrcfilelist(FileList fl) {
sourceFileLists.addElement(fl); sourceFileLists.addElement(fl);
@@ -106,6 +108,7 @@ public class DependSet extends MatchingTask {


/** /**
* Add a set of target files. * Add a set of target files.
* @param fs the FileSet to add.
*/ */
public void addTargetfileset(FileSet fs) { public void addTargetfileset(FileSet fs) {
targetFileSets.addElement(fs); targetFileSets.addElement(fs);
@@ -113,6 +116,7 @@ public class DependSet extends MatchingTask {


/** /**
* Add a list of target files. * Add a list of target files.
* @param fl the FileList to add.
*/ */
public void addTargetfilelist(FileList fl) { public void addTargetfilelist(FileList fl) {
targetFileLists.addElement(fl); targetFileLists.addElement(fl);
@@ -120,20 +124,18 @@ public class DependSet extends MatchingTask {


/** /**
* Executes the task. * Executes the task.
* @throws BuildException if errors occur.
*/ */

public void execute() throws BuildException { public void execute() throws BuildException {


if ((sourceFileSets.size() == 0) && (sourceFileLists.size() == 0)) { if ((sourceFileSets.size() == 0) && (sourceFileLists.size() == 0)) {
throw new BuildException("At least one <srcfileset> or <srcfilelist>" throw new BuildException("At least one <srcfileset> or <srcfilelist>"
+ " element must be set"); + " element must be set");
} }

if ((targetFileSets.size() == 0) && (targetFileLists.size() == 0)) { if ((targetFileSets.size() == 0) && (targetFileLists.size() == 0)) {
throw new BuildException("At least one <targetfileset> or" throw new BuildException("At least one <targetfileset> or"
+ " <targetfilelist> element must be set"); + " <targetfilelist> element must be set");
} }

long now = (new Date()).getTime(); long now = (new Date()).getTime();
/* /*
We have to munge the time to allow for the filesystem time We have to munge the time to allow for the filesystem time
@@ -141,10 +143,8 @@ public class DependSet extends MatchingTask {
*/ */
now += FILE_UTILS.getFileTimestampGranularity(); now += FILE_UTILS.getFileTimestampGranularity();


//
// Grab all the target files specified via filesets
//
Vector allTargets = new Vector();
// Grab all the target files specified via filesets:
Vector allTargets = new Vector();
long oldestTargetTime = 0; long oldestTargetTime = 0;
File oldestTarget = null; File oldestTarget = null;
Enumeration enumTargetSets = targetFileSets.elements(); Enumeration enumTargetSets = targetFileSets.elements();
@@ -155,7 +155,6 @@ public class DependSet extends MatchingTask {
// this is the same as if it was empty, no target files found // this is the same as if it was empty, no target files found
continue; continue;
} }

DirectoryScanner targetDS = targetFS.getDirectoryScanner(getProject()); DirectoryScanner targetDS = targetFS.getDirectoryScanner(getProject());
String[] targetFiles = targetDS.getIncludedFiles(); String[] targetFiles = targetDS.getIncludedFiles();


@@ -168,7 +167,6 @@ public class DependSet extends MatchingTask {
log("Warning: " + targetFiles[i] + " modified in the future.", log("Warning: " + targetFiles[i] + " modified in the future.",
Project.MSG_WARN); Project.MSG_WARN);
} }

if (oldestTarget == null if (oldestTarget == null
|| dest.lastModified() < oldestTargetTime) { || dest.lastModified() < oldestTargetTime) {
oldestTargetTime = dest.lastModified(); oldestTargetTime = dest.lastModified();
@@ -176,11 +174,8 @@ public class DependSet extends MatchingTask {
} }
} }
} }

//
// Grab all the target files specified via filelists
//
boolean upToDate = true;
// Grab all the target files specified via filelists:
boolean upToDate = true;
Enumeration enumTargetLists = targetFileLists.elements(); Enumeration enumTargetLists = targetFileLists.elements();
while (enumTargetLists.hasMoreElements()) { while (enumTargetLists.hasMoreElements()) {


@@ -201,7 +196,6 @@ public class DependSet extends MatchingTask {
log("Warning: " + targetFiles[i] + " modified in the future.", log("Warning: " + targetFiles[i] + " modified in the future.",
Project.MSG_WARN); Project.MSG_WARN);
} }

if (oldestTarget == null if (oldestTarget == null
|| dest.lastModified() < oldestTargetTime) { || dest.lastModified() < oldestTargetTime) {
oldestTargetTime = dest.lastModified(); oldestTargetTime = dest.lastModified();
@@ -216,10 +210,7 @@ public class DependSet extends MatchingTask {
// skip the following tests right away // skip the following tests right away
upToDate = false; upToDate = false;
} }

//
// Check targets vs source files specified via filelists
//
// Check targets vs source files specified via filelists:
if (upToDate) { if (upToDate) {
Enumeration enumSourceLists = sourceFileLists.elements(); Enumeration enumSourceLists = sourceFileLists.elements();
while (upToDate && enumSourceLists.hasMoreElements()) { while (upToDate && enumSourceLists.hasMoreElements()) {
@@ -234,14 +225,12 @@ public class DependSet extends MatchingTask {
log("Warning: " + sourceFiles[i] log("Warning: " + sourceFiles[i]
+ " modified in the future.", Project.MSG_WARN); + " modified in the future.", Project.MSG_WARN);
} }

if (!src.exists()) { if (!src.exists()) {
log(sourceFiles[i] + " does not exist.", log(sourceFiles[i] + " does not exist.",
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
upToDate = false; upToDate = false;
break; break;
} }

if (src.lastModified() > oldestTargetTime) { if (src.lastModified() > oldestTargetTime) {
upToDate = false; upToDate = false;
log(oldestTarget + " is out of date with respect to " log(oldestTarget + " is out of date with respect to "
@@ -250,15 +239,12 @@ public class DependSet extends MatchingTask {
} }
} }
} }

//
// Check targets vs source files specified via filesets
//
// Check targets vs source files specified via filesets:
if (upToDate) { if (upToDate) {
Enumeration enumSourceSets = sourceFileSets.elements(); Enumeration enumSourceSets = sourceFileSets.elements();
while (upToDate && enumSourceSets.hasMoreElements()) { while (upToDate && enumSourceSets.hasMoreElements()) {


FileSet sourceFS = (FileSet) enumSourceSets.nextElement();
FileSet sourceFS = (FileSet) enumSourceSets.nextElement();
DirectoryScanner sourceDS = sourceFS.getDirectoryScanner(getProject()); DirectoryScanner sourceDS = sourceFS.getDirectoryScanner(getProject());
String[] sourceFiles = sourceDS.getIncludedFiles(); String[] sourceFiles = sourceDS.getIncludedFiles();


@@ -269,7 +255,6 @@ public class DependSet extends MatchingTask {
log("Warning: " + sourceFiles[i] log("Warning: " + sourceFiles[i]
+ " modified in the future.", Project.MSG_WARN); + " modified in the future.", Project.MSG_WARN);
} }

if (src.lastModified() > oldestTargetTime) { if (src.lastModified() > oldestTargetTime) {
upToDate = false; upToDate = false;
log(oldestTarget + " is out of date with respect to " log(oldestTarget + " is out of date with respect to "
@@ -278,7 +263,6 @@ public class DependSet extends MatchingTask {
} }
} }
} }

if (!upToDate) { if (!upToDate) {
log("Deleting all target files. ", Project.MSG_VERBOSE); log("Deleting all target files. ", Project.MSG_VERBOSE);
for (Enumeration e = allTargets.elements(); e.hasMoreElements();) { for (Enumeration e = allTargets.elements(); e.hasMoreElements();) {
@@ -288,7 +272,5 @@ public class DependSet extends MatchingTask {
fileToRemove.delete(); fileToRemove.delete();
} }
} }

} //-- execute

} //-- DependSet.java
}
}

Loading…
Cancel
Save