Throw a BuildException if Velocity fails so that we don't write bogus data back
out to the source file.
This commit is contained in:
@@ -125,6 +125,7 @@ public class GenRecordTask extends Task
|
|||||||
name = readClassName(source);
|
name = readClassName(source);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Failed to parse " + source + ": " + e.getMessage());
|
System.err.println("Failed to parse " + source + ": " + e.getMessage());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -389,14 +390,13 @@ public class GenRecordTask extends Task
|
|||||||
/** Helper function for generating our boilerplate code. */
|
/** Helper function for generating our boilerplate code. */
|
||||||
protected String mergeTemplate (String tmpl, VelocityContext ctx)
|
protected String mergeTemplate (String tmpl, VelocityContext ctx)
|
||||||
{
|
{
|
||||||
StringWriter writer = new StringWriter();
|
|
||||||
try {
|
try {
|
||||||
|
StringWriter writer = new StringWriter();
|
||||||
_velocity.mergeTemplate(tmpl, "UTF-8", ctx, writer);
|
_velocity.mergeTemplate(tmpl, "UTF-8", ctx, writer);
|
||||||
|
return writer.toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Failed processing template [tmpl=" + tmpl + "]");
|
throw new BuildException("Failed processing template [tmpl=" + tmpl + "]", e);
|
||||||
e.printStackTrace(System.err);
|
|
||||||
}
|
}
|
||||||
return writer.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean hasAnnotation (Field field, Class<?> annotation)
|
protected static boolean hasAnnotation (Field field, Class<?> annotation)
|
||||||
|
|||||||
Reference in New Issue
Block a user