The FOP Ant task currently always renders the output. The attached patch will render only when the source file (.fo) is newer then the target (.pdf, etc.). There is also a "force" flag that can be used to always render. cvs diff -u src/documentation/content/xdocs/anttask.xml src/org/apache/fop/tools/anttasks/Fop.java Index: src/documentation/content/xdocs/anttask.xml =================================================================== RCS file: /home/cvspublic/xml-fop/src/documentation/content/xdocs/anttask.xml,v retrieving revision 1.3.2.1 diff -u -u -r1.3.2.1 anttask.xml --- src/documentation/content/xdocs/anttask.xml 19 May 2003 11:20:27 -0000 1.3.2.1 +++ src/documentation/content/xdocs/anttask.xml 7 Jul 2003 20:38:12 -0000 @@ -90,7 +90,12 @@ (<code>true</code>) or not (<code>false</code>)</td> <td>No, default is <code>true</code></td> </tr> - </table> + <tr> + <td>force</td> + <td>Recreate target files, even if they are newer than their corresponding source files.</td> + <td>No, default is <code>true</code></td> + </tr> + </table> <p/> <table><caption>Parameters specified as nested elements</caption> <tr> @@ -104,7 +109,7 @@ are used to specify multiple XSL-FO files to be rendered.</td> <td>Yes, if no fofile attribute is supplied</td> </tr> - </table> + </table> </section> <section> <title>Examples</title> Index: src/org/apache/fop/tools/anttasks/Fop.java =================================================================== RCS file: /home/cvspublic/xml-fop/src/org/apache/fop/tools/anttasks/Attic/Fop.java,v retrieving revision 1.14.2.8 diff -u -u -r1.14.2.8 Fop.java --- src/org/apache/fop/tools/anttasks/Fop.java 25 Feb 2003 15:19:58 -0000 1.14.2.8 +++ src/org/apache/fop/tools/anttasks/Fop.java 7 Jul 2003 20:38:12 -0000 @@ -92,6 +92,7 @@ * <li>userconfig -> file with user configuration (same as the "-c" command line option)</li> * <li>messagelevel -> (error | warn | info | verbose | debug) level to output non-error messages</li> * <li>logFiles -> Controls whether the names of the files that are processed are logged or not</li> + * <li>force -> Recreate target files, even if they are newer than their corresponding source files</li> * </ul> */ public class Fop extends Task { @@ -105,6 +106,7 @@ File userConfig; int messageType = Project.MSG_VERBOSE; boolean logFiles = true; + boolean force = true; // Ignore modification dates if true /** * Sets the input file @@ -238,6 +240,20 @@ } /** + * Sets force (ignore mod dates) flag + */ + public void setForce(boolean aBoolean) { + this.force = aBoolean; + } + + /** + * Gets force (ignore mod dates) flag + */ + public boolean getForce() { + return this.force; + } + + /** * Starts execution of this task */ public void execute() throws BuildException { @@ -369,8 +385,13 @@ if (task.getOutdir() != null) { outf = new File(task.getOutdir(), outf.getName()); } - render(task.getFofile(), outf, rint); - actioncount++; + // Only render if "force" flag is set OR output file doesn't exist OR + // output file is older than input file + if ( task.force || !outf.exists() || + (task.getFofile().lastModified() > outf.lastModified() ) ) { + render(task.getFofile(), outf, rint); + actioncount++; + } } } @@ -413,15 +434,17 @@ task.log("Error setting base directory: " + e, Project.MSG_ERR); } - render(f, outf, rint); - actioncount++; + // Only render if "force" flag is set OR output file doesn't exist OR + // output file is older than input file + if ( task.force || !outf.exists() || (f.lastModified() > outf.lastModified() ) ) { + render(f, outf, rint); + actioncount++; + } } } if (actioncount == 0) { - task.log( - "No files processed. No files were selected by the filesets and no fofile was set." , - Project.MSG_WARN); + task.log("Nothing to do." , Project.MSG_WARN); } }
Added to both maintenance and development branches. Thanks for the submission!
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed