If the pluging is aborted, because of an exception, a stracktrace is printed
authorKai Moritz <kai@juplo.de>
Tue, 7 Feb 2017 12:13:48 +0000 (13:13 +0100)
committerKai Moritz <kai@juplo.de>
Tue, 7 Feb 2017 12:13:48 +0000 (13:13 +0100)
src/main/java/de/juplo/plugins/hibernate/AbstractSchemaMojo.java

index 28260f0..0f143f5 100644 (file)
@@ -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();
+    }
+  }
 }