From: Kai Moritz Date: Tue, 7 Feb 2017 12:13:48 +0000 (+0100) Subject: If the pluging is aborted, because of an exception, a stracktrace is printed X-Git-Tag: hibernate-maven-plugin-2.1.0~6 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=78e911b4b7571b8fb43ff5d0370f9486107cbeb7;p=hibernate4-maven-plugin If the pluging is aborted, because of an exception, a stracktrace is printed --- diff --git a/src/main/java/de/juplo/plugins/hibernate/AbstractSchemaMojo.java b/src/main/java/de/juplo/plugins/hibernate/AbstractSchemaMojo.java index 28260f06..0f143f59 100644 --- a/src/main/java/de/juplo/plugins/hibernate/AbstractSchemaMojo.java +++ b/src/main/java/de/juplo/plugins/hibernate/AbstractSchemaMojo.java @@ -741,6 +741,8 @@ public abstract class AbstractSchemaMojo extends AbstractMojo { builder.append("\n * "); builder.append(e.getMessage()); + AbstractSchemaMojo.printStrackTrace(builder, e); + builder.append("\n"); } String error = builder.toString(); getLog().error(error); @@ -1395,4 +1397,24 @@ public abstract class AbstractSchemaMojo extends AbstractMojo throw new MojoFailureException("Could not find persistence-unit " + persistenceUnit); } + + + public static void printStrackTrace(StringBuilder builder, Throwable t) + { + while (t != null) + { + builder.append("\n\tCause: "); + builder.append(t.getMessage() == null ? "" : t.getMessage().replaceAll("\\s+", " ")); + for (StackTraceElement trace : t.getStackTrace()) + { + builder.append("\n\t"); + builder.append(trace.getClassName()); + builder.append("."); + builder.append(trace.getMethodName()); + builder.append("():"); + builder.append(trace.getLineNumber()); + } + t = t.getCause(); + } + } }