gmazza 2003/07/30 15:01:35
Modified: src/documentation/content/xdocs anttask.xml
src/java/org/apache/fop/tools/anttasks Fop.java
Log:
Patch 21381: New "force" attribute added to FOP task, update to documentation.
Submitted by: Sean Gilligan (seanlist at msgilligan dot com)
Revision Changes Path
1.5 +5 -0 xml-fop/src/documentation/content/xdocs/anttask.xml
Index: anttask.xml
===================================================================
RCS file: /home/cvs/xml-fop/src/documentation/content/xdocs/anttask.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- anttask.xml 27 Jul 2003 17:59:36 -0000 1.4
+++ anttask.xml 30 Jul 2003 22:01:35 -0000 1.5
@@ -68,6 +68,11 @@
<td>Output directory</td>
<td>Required if a fileset is used to specify the files to render; optional
for fofile. (Can alternatively specify the full path in the fofile value.)</td>
</tr>
+ <!--tr Commented out; implemented only in 1.0 currently>
+ <td>force</td>
+ <td>If <code>true</code>, always generate target file, even if source file
has not changed.</td>
+ <td>No, default is <code>false</code></td>
+ </tr-->
<!--tr Commented out; attribute is currently unimplemented according to the
code>
<td>basedir</td>
<td>Directory to work from</td>
1.6 +50 -7 xml-fop/src/java/org/apache/fop/tools/anttasks/Fop.java
Index: Fop.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/tools/anttasks/Fop.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Fop.java 27 Jul 2003 16:37:14 -0000 1.5
+++ Fop.java 30 Jul 2003 22:01:35 -0000 1.6
@@ -104,6 +104,7 @@
private File userConfig;
private int messageType = Project.MSG_VERBOSE;
private boolean logFiles = true;
+ private boolean force = false;
/**
* Sets the filename for the userconfig.xml.
@@ -154,6 +155,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 outFile File to output to
*/
@@ -265,7 +284,7 @@
public boolean getLogFiles() {
return this.logFiles;
}
-
+
/**
* @see org.apache.tools.ant.Task#execute()
*/
@@ -395,7 +414,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) {
@@ -407,8 +429,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++;
+ }
}
}
@@ -446,14 +477,26 @@
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);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]