gmazza 2003/10/17 15:21:09 Modified: src/org/apache/fop/tools/anttasks Tag: fop-0_20_2-maintain Fop.java Log: Addition of force attribute to ant task in maintenance branch. Submitted by: Sean Gilligan (Bug 21380). Revision Changes Path No revision No revision 1.14.2.9 +52 -9 xml-fop/src/org/apache/fop/tools/anttasks/Attic/Fop.java Index: Fop.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/tools/anttasks/Attic/Fop.java,v retrieving revision 1.14.2.8 retrieving revision 1.14.2.9 diff -u -r1.14.2.8 -r1.14.2.9 --- Fop.java 25 Feb 2003 15:19:58 -0000 1.14.2.8 +++ Fop.java 17 Oct 2003 22:21:08 -0000 1.14.2.9 @@ -105,6 +105,7 @@ File userConfig; int messageType = Project.MSG_VERBOSE; boolean logFiles = true; + private boolean force = false; /** * Sets the input file @@ -137,6 +138,24 @@ } /** + * 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 File to output to */ @@ -357,7 +376,10 @@ 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) { @@ -369,8 +391,17 @@ 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++; + } } } @@ -413,15 +444,27 @@ task.log("Error setting base directory: " + e, Project.MSG_ERR); } - 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) { - task.log( - "No files processed. No files were selected by the filesets and no fofile was set." , - Project.MSG_WARN); + 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); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]