+ /**
+ * Add mappings from the default mapping-file
+ * <code>META-INF/orm.xml</code>, if present
+ */
+ boolean error = false;
+ InputStream is;
+ is = classLoader.getResourceAsStream("META-INF/orm.xml");
+ if (is != null)
+ {
+ getLog().info("Adding default JPA-XML-mapping from META-INF/orm.xml");
+ try
+ {
+ tracker.track("META-INF/orm.xml", is);
+ sources.addResource("META-INF/orm.xml");
+ }
+ catch (IOException e)
+ {
+ getLog().error("cannot read META-INF/orm.xml: " + e);
+ error = true;
+ }
+ }
+ else
+ {
+ getLog().debug("no META-INF/orm.xml found");
+ }
+ /**
+ * 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);
+ is = classLoader.getResourceAsStream(mapping);
+ if (is != null)
+ {
+ try
+ {
+ tracker.track(mapping, is);
+ sources.addResource(mapping);
+ }
+ catch (IOException e)
+ {
+ getLog().info("cannot read mapping-file " + mapping + ": " + e);
+ error = true;
+ }
+ }
+ else
+ {
+ getLog().error("cannot find mapping-file " + mapping);
+ error = true;
+ }
+ }
+ if (error)
+ throw new MojoFailureException(
+ "error, while reading mappings configured in persistence-unit \"" +
+ unit.getName() +
+ "\""
+ );