private File userConfig;
private int messageType = Project.MSG_VERBOSE;
private boolean logFiles = true;
+ private boolean force = false;
/**
* Sets the filename for the userconfig.xml.
return this.filesets;
}
+ /**
+ * Set whether to check dependencies, or to always generate;
+ * optional, default is false.
+ *
+ * @param force true if always generate.
+ */
+ public void setForce(boolean force) {
+ this.force = force;
+ }
+
+ /**
+ * Gets the force attribute
+ * @return the force attribute
+ */
+ public boolean getForce() {
+ return force;
+ }
+
/**
* Sets the output file.
* @param outFile File to output to
public boolean getLogFiles() {
return this.logFiles;
}
-
+
/**
* @see org.apache.tools.ant.Task#execute()
*/
int rint = determineRenderer(task.getFormat());
String newExtension = determineExtension(rint);
+ // actioncount = # of fofiles actually processed through FOP
int actioncount = 0;
+ // skippedcount = # of fofiles which haven't changed (force = "false")
+ int skippedcount = 0;
// deal with single source file
if (task.getFofile() != null) {
if (task.getOutdir() != null) {
outf = new File(task.getOutdir(), outf.getName());
}
- render(task.getFofile(), outf, rint);
- actioncount++;
+
+ // Render if "force" flag is set OR
+ // OR output file doesn't exist OR
+ // output file is older than input file
+ if (task.getForce() || !outf.exists()
+ || (task.getFofile().lastModified() > outf.lastModified() )) {
+ render(task.getFofile(), outf, rint);
+ actioncount++;
+ } else if (outf.exists() && (task.getFofile().lastModified() <= outf.lastModified() )) {
+ skippedcount++;
+ }
}
}
task.log("Error setting base URL", Project.MSG_DEBUG);
}
- render(f, outf, rint);
- actioncount++;
+ // Render if "force" flag is set OR
+ // OR output file doesn't exist OR
+ // output file is older than input file
+ if (task.getForce() || !outf.exists()
+ || (f.lastModified() > outf.lastModified() )) {
+ render(f, outf, rint);
+ actioncount++;
+ } else if (outf.exists() && (f.lastModified() <= outf.lastModified() )) {
+ skippedcount++;
+ }
}
}
-
- if (actioncount == 0) {
+
+ if (actioncount + skippedcount == 0) {
task.log("No files processed. No files were selected by the filesets "
+ "and no fofile was set." , Project.MSG_WARN);
+ } else if (skippedcount > 0) {
+ task.log(skippedcount + " xslfo file(s) skipped (no change found"
+ + " since last generation; set force=\"true\" to override)."
+ , Project.MSG_INFO);
}
}