Added a warning, if a directory, that should be scanned, does not exist
[hibernate4-maven-plugin] / src / main / java / de / juplo / plugins / hibernate / AbstractSchemaMojo.java
index 20c326a..28260f0 100644 (file)
@@ -733,12 +733,23 @@ public abstract class AbstractSchemaMojo extends AbstractMojo
       {
         thread.setContextClassLoader(classLoader);
         build((MetadataImplementor)metadataBuilder.build(), options, target);
+        if (handler.getExceptions().size() > 0)
+        {
+          StringBuilder builder = new StringBuilder();
+          builder.append("Hibernate failed:");
+          for (Exception e : handler.getExceptions())
+          {
+            builder.append("\n * ");
+            builder.append(e.getMessage());
+          }
+          String error = builder.toString();
+          getLog().error(error);
+          throw new MojoFailureException(error);
+        }
       }
       finally
       {
         thread.setContextClassLoader(contextClassLoader);
-        for (Exception e : handler.getExceptions())
-          getLog().error(e.getMessage());
         /** Track, the content of the generated script */
         checkOutputFile(output, tracker);
       }
@@ -1168,12 +1179,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)
     {