* If set to <code>true</code>, the execution is skipped.
* <p>
* A skipped execution is signaled via the maven-property
- * <code>${hibernate.export.skipped}</code>.
+ * <code>${hibernate.schema.skipped}</code>.
* <p>
* The execution is skipped automatically, if no modified or newly added
* annotated classes are found and the dialect was not changed.
classes = scanUrls(urls);
for (String className : unit.getManagedClassNames())
classes.add(className);
+ /**
+ * Add mappings from the default mapping-file
+ * <code>META-INF/orm.xml</code>, if present
+ */
+ try
+ {
+ InputStream is = classLoader.getResourceAsStream("META-INF/orm.xml");
+ if (is != null)
+ {
+ getLog().info("Adding default JPA-XML-mapping from META-INF/orm.xml");
+ tracker.track("META-INF/orm.xml", is);
+ sources.addResource("META-INF/orm.xml");
+ }
+ /**
+ * Add mappings from files, that are explicitly configured in the
+ * persistence unit
+ */
+ for (String mapping : unit.getMappingFileNames())
+ {
+ getLog().info("Adding explicitly configured mapping from " + mapping);
+ tracker.track(mapping, classLoader.getResourceAsStream(mapping));
+ sources.addResource(mapping);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new MojoFailureException("Error reading XML-mappings", e);
+ }
}
/** Add the configured/collected annotated classes */
thread.setContextClassLoader(contextClassLoader);
}
}
+ catch (MojoExecutionException e)
+ {
+ tracker.failed();
+ throw e;
+ }
+ catch (MojoFailureException e)
+ {
+ tracker.failed();
+ throw e;
+ }
+ catch (RuntimeException e)
+ {
+ tracker.failed();
+ throw e;
+ }
finally
{
/** Remember mappings and configuration */
packageName = name;
}
- if (!packages.contains(packageName))
+ while (packageName != null)
{
+ if (packages.contains(packageName))
+ return;
String resource = packageName.replace('.', '/') + "/package-info.class";
InputStream is = classLoaderService.locateResourceStream(resource);
if (is == null)
getLog().debug("New or modified package: " + packageName);
else
getLog().debug("Unchanged package: " + packageName);
- getLog().info("Adding annotated package " + packageName);
+ getLog().info("Adding annotations from package " + packageName);
sources.addPackage(packageName);
}
packages.add(packageName);
+ int i = packageName.lastIndexOf('.');
+ if (i < 0)
+ packageName = null;
+ else
+ packageName = packageName.substring(0,i);
}
}
catch (Exception e)