From 78e911b4b7571b8fb43ff5d0370f9486107cbeb7 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 7 Feb 2017 13:13:48 +0100 Subject: [PATCH] If the pluging is aborted, because of an exception, a stracktrace is printed --- .../plugins/hibernate/AbstractSchemaMojo.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) 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(); + } + } } -- 2.20.1