aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/codegen/java/org/apache/fop/tools/EventProducerCollector.java18
-rw-r--r--src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java23
2 files changed, 28 insertions, 13 deletions
diff --git a/src/codegen/java/org/apache/fop/tools/EventProducerCollector.java b/src/codegen/java/org/apache/fop/tools/EventProducerCollector.java
index ebb960a8e..2e008a130 100644
--- a/src/codegen/java/org/apache/fop/tools/EventProducerCollector.java
+++ b/src/codegen/java/org/apache/fop/tools/EventProducerCollector.java
@@ -46,7 +46,7 @@ public class EventProducerCollector {
private static final String CLASSNAME_EVENT_PRODUCER = EventProducer.class.getName();
private static final Map PRIMITIVE_MAP;
-
+
static {
Map m = new java.util.HashMap();
m.put("boolean", Boolean.class);
@@ -59,7 +59,7 @@ public class EventProducerCollector {
m.put("double", Double.class);
PRIMITIVE_MAP = Collections.unmodifiableMap(m);
}
-
+
private DocletTagFactory tagFactory;
private EventModel model = new EventModel();
@@ -81,21 +81,25 @@ public class EventProducerCollector {
/**
* Scans a file and processes it if it extends the {@link EventProducer} interface.
* @param src the source file (a Java source file)
+ * @return true if the file contained an EventProducer interface
* @throws IOException if an I/O error occurs
* @throws EventConventionException if the EventProducer conventions are violated
* @throws ClassNotFoundException if a required class cannot be found
*/
- public void scanFile(File src)
+ public boolean scanFile(File src)
throws IOException, EventConventionException, ClassNotFoundException {
JavaDocBuilder builder = new JavaDocBuilder(this.tagFactory);
builder.addSource(src);
JavaClass[] classes = builder.getClasses();
+ boolean eventProducerFound = false;
for (int i = 0, c = classes.length; i < c; i++) {
JavaClass clazz = classes[i];
if (clazz.isInterface() && implementsInterface(clazz, CLASSNAME_EVENT_PRODUCER)) {
processEventProducerInterface(clazz);
+ eventProducerFound = true;
}
}
+ return eventProducerFound;
}
private boolean implementsInterface(JavaClass clazz, String intf) {
@@ -146,13 +150,13 @@ public class EventProducerCollector {
throw new EventConventionException("The first parameter of the method " + methodSig
+ " must be: 'Object source'!");
}
-
+
//build method model
DocletTag tag = method.getTagByName("event.severity");
EventSeverity severity;
if (tag != null) {
severity = EventSeverity.valueOf(tag.getValue());
- } else {
+ } else {
severity = EventSeverity.INFO;
}
EventMethodModel methodMeta = new EventMethodModel(
@@ -192,7 +196,7 @@ public class EventProducerCollector {
public EventModel getModel() {
return this.model;
}
-
+
/**
* Saves the accumulated event model to an XML file.
* @param modelFile the target model file
@@ -201,5 +205,5 @@ public class EventProducerCollector {
public void saveModelToXML(File modelFile) throws IOException {
getModel().saveToXML(modelFile);
}
-
+
}
diff --git a/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java b/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java
index e00b05b55..b089a361e 100644
--- a/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java
+++ b/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java
@@ -63,16 +63,21 @@ public class EventProducerCollectorTask extends Task {
public void execute() throws BuildException {
try {
EventProducerCollector collector = new EventProducerCollector();
- processFileSets(collector);
+ long lastModified = processFileSets(collector);
File parentDir = getModelFile().getParentFile();
if (!parentDir.exists() && !parentDir.mkdirs()) {
throw new BuildException(
"Could not create target directory for event model file: " + parentDir);
}
- collector.saveModelToXML(getModelFile());
- log("Event model written to " + getModelFile());
+ if (!getModelFile().exists() || lastModified > getModelFile().lastModified()) {
+ collector.saveModelToXML(getModelFile());
+ log("Event model written to " + getModelFile());
+ }
if (getTranslationFile() != null) {
- updateTranslationFile();
+ if (!getTranslationFile().exists()
+ || lastModified > getTranslationFile().lastModified()) {
+ updateTranslationFile();
+ }
}
} catch (ClassNotFoundException e) {
throw new BuildException(e);
@@ -164,12 +169,14 @@ public class EventProducerCollectorTask extends Task {
/**
* Processes the file sets defined for the task.
* @param collector the collector to use for collecting the event producers
+ * @return the time of the latest modification of any of the files inspected
* @throws IOException if an I/O error occurs
* @throws EventConventionException if the EventProducer conventions are violated
* @throws ClassNotFoundException if a required class cannot be found
*/
- protected void processFileSets(EventProducerCollector collector)
+ protected long processFileSets(EventProducerCollector collector)
throws IOException, EventConventionException, ClassNotFoundException {
+ long lastModified = 0;
Iterator iter = filesets.iterator();
while (iter.hasNext()) {
FileSet fs = (FileSet)iter.next();
@@ -179,9 +186,13 @@ public class EventProducerCollectorTask extends Task {
for (int i = 0, c = srcFiles.length; i < c; i++) {
String filename = srcFiles[i];
File src = new File(directory, filename);
- collector.scanFile(src);
+ boolean eventProducerFound = collector.scanFile(src);
+ if (eventProducerFound) {
+ lastModified = Math.max(lastModified, src.lastModified());
+ }
}
}
+ return lastModified;
}
/**