If the pluging is aborted, because of an exception, a stracktrace is printed
[hibernate4-maven-plugin] / src / main / java / de / juplo / plugins / hibernate / AbstractSchemaMojo.java
index c9ef2c5..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);
@@ -1179,12 +1181,18 @@ public abstract class AbstractSchemaMojo extends AbstractMojo
   {
     try
     {
-      File dir = new File(outputDirectory);
+      File dir = new File(path);
       if (dir.exists())
       {
         getLog().info("Adding " + dir.getAbsolutePath() + " to the list of roots to scan...");
         urls.add(dir.toURI().toURL());
       }
+      else
+        getLog().warn(
+            "the directory cannot be scanned for annotated classes, " +
+            "because it does not exist: " +
+            dir.getAbsolutePath()
+            );
     }
     catch (MalformedURLException e)
     {
@@ -1389,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();
+    }
+  }
 }