You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by bu...@apache.org on 2003/07/07 22:47:21 UTC
DO NOT REPLY [Bug 21381] New: -
[PATCH] Ant task mod-date patch for dev branch (see #21380)
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21381>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21381
[PATCH] Ant task mod-date patch for dev branch (see #21380)
Summary: [PATCH] Ant task mod-date patch for dev branch (see
#21380)
Product: Fop
Version: 1.0dev
Platform: All
OS/Version: All
Status: NEW
Severity: Enhancement
Priority: Other
Component: general
AssignedTo: fop-dev@xml.apache.org
ReportedBy: seanlist@msgilligan.com
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.
This is the patch for org.apache.fop.tools.anttasks.Fop on the HEAD branch that
corresponds to the patch on the 0_20_2-maintain branch. (The changes to the XML
documentation are the same for both branches.)
cvs diff -u src/java/org/apache/fop/tools/anttasks/Fop.java
Index: src/java/org/apache/fop/tools/anttasks/Fop.java
===================================================================
RCS file: /home/cvspublic/xml-fop/src/java/org/apache/fop/tools/anttasks/Fop.java,v
retrieving revision 1.4
diff -u -u -r1.4 Fop.java
--- src/java/org/apache/fop/tools/anttasks/Fop.java 17 Jun 2003 16:35:58
-0000 1.4
+++ src/java/org/apache/fop/tools/anttasks/Fop.java 7 Jul 2003 20:44:17 -0000
@@ -94,6 +94,8 @@
* 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 {
@@ -107,6 +109,7 @@
private File userConfig;
private int messageType = Project.MSG_VERBOSE;
private boolean logFiles = true;
+ boolean force = false; // Ignore modification dates if true
/**
* Sets the filename for the userconfig.xml.
@@ -270,6 +273,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;
+ }
+
+ /**
* @see org.apache.tools.ant.Task#execute()
*/
public void execute() throws BuildException {
@@ -410,8 +427,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++;
+ }
}
}
@@ -449,14 +471,17 @@
task.log("Error setting base URL", Project.MSG_DEBUG);
}
- 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);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org