protected void configureHyperjaxb3Mojo(Hyperjaxb3Mojo mojo) { final MavenProject project = new MavenProject(); mojo.setProject(project); mojo.setExtension(true); mojo.setDebug(true); // mojo.setBvariant = "ejb"; mojo.roundtripTestClassName = getClass().getPackage().getName() + ".RoundtripTest"; mojo.setForceRegenerate(true); }
public boolean mojo(List<String> args, MOJO_VARIANTS variant) { boolean success = false; try { File pom = new File(folder.getPath() + File.separator + "pom.xml"); if (!pom.exists()) { success = streamMockPOM(pom, model.getName()); } MavenProject mp = new MavenProject(); final Hyperjaxb3Mojo mojo = new Hyperjaxb3Mojo(); mojo.setVerbose(true); mojo.setBindingDirectory(getMetaInfDir()); mojo.setSchemaDirectory(getMetaInfDir()); int j = 0; String[] excludedSchemas = new String[preexistingSchemas.size()]; for (File f : preexistingSchemas) { excludedSchemas[j++] = f.getName(); } mojo.setSchemaExcludes(excludedSchemas); int k = 0; String[] excludedBindings = new String[preesistingBindings.size()]; for (File f : preesistingBindings) { excludedBindings[k++] = f.getName(); } mojo.setBindingExcludes(excludedBindings); mojo.setGenerateDirectory(getXjcDir()); mojo.setExtension(true); mojo.variant = variant.getLabel(); File perx = new File( getBinDir().getPath() + File.separator + "META-INF" + File.separator + "persistence.xml"); if (perx.exists()) { mojo.persistenceXml = perx; try { Document dox = parseXML(perx); XPath xpath = XPathFactory.newInstance().newXPath(); XPathExpression expr = xpath.compile("//persistence-unit/@name"); mojo.persistenceUnitName = (String) expr.evaluate(dox, XPathConstants.STRING); } catch (Exception e) { mojo.persistenceXml = new File(getMetaInfDir() + File.separator + "persistence-template-hibernate.xml"); mojo.persistenceUnitName = model.getName(); } } else { mojo.persistenceXml = new File(getMetaInfDir() + File.separator + "persistence-template-hibernate.xml"); mojo.persistenceUnitName = model.getName(); } mojo.generateEquals = false; mojo.generateHashCode = false; mojo.setProject(mp); mojo.setArgs(args); mojo.setForceRegenerate(true); mojo.execute(); success = true; } catch (MojoExecutionException e) { e.printStackTrace(); } return success; }