use of org.apache.maven.plugin.MojoExecutionException in project midpoint by Evolveum.
the class SchemaDocMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("SchemaDoc plugin started");
PrismContext prismContext = createInitializedPrismContext();
File outDir = initializeOutDir();
PathGenerator pathGenerator = new PathGenerator(outDir);
VelocityEngine velocityEngine = createVelocityEngine();
SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
try {
renderSchemaIndex(schemaRegistry, prismContext, velocityEngine, pathGenerator);
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
for (PrismSchema schema : schemaRegistry.getSchemas()) {
try {
renderSchema(schema, prismContext, velocityEngine, pathGenerator);
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
try {
copyResources(outDir);
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
File archiveFile = null;
try {
archiveFile = generateArchive(outDir, finalName + "-schemadoc.zip");
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
} catch (ArchiverException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
projectHelper.attachArtifact(project, "zip", "schemadoc", archiveFile);
getLog().info("SchemaDoc plugin finished");
}
use of org.apache.maven.plugin.MojoExecutionException in project OpenAM by OpenRock.
the class CLIDefinitionGenerator method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
for (String className : definitions) {
try {
Class clazz = Class.forName(className);
Field pdtField = clazz.getDeclaredField("product");
if (pdtField != null) {
DefinitionClassInfo classInfo = pdtField.getAnnotation(DefinitionClassInfo.class);
PrintStream rbOut = createResourcePrintStream(outputDir, classInfo);
getCommonResourceStrings(rbOut, clazz);
rbOut.println("product-name=" + classInfo.productName());
getCommands(className, clazz, rbOut);
rbOut.close();
} else {
throw new Exception("Incorrect Definiton, class=" + className + " missing product field");
}
} catch (Exception ex) {
throw new MojoFailureException("An error occured while generating CLI resources", ex);
}
}
Resource resource = new Resource();
resource.setDirectory(outputDir);
project.addResource(resource);
}
use of org.apache.maven.plugin.MojoExecutionException in project OpenAM by OpenRock.
the class InjectContentTest method shouldThrowMojoExecutionExceptionWithUnknownContentConverter.
@Test(expectedExceptions = MojoExecutionException.class)
public void shouldThrowMojoExecutionExceptionWithUnknownContentConverter() throws MojoExecutionException, IOException {
//Given
File contentFile = mock(File.class);
BufferedReader destinationFileReader = mock(BufferedReader.class);
BufferedWriter tmpFileWriter = mock(BufferedWriter.class);
File temporaryFile = mock(File.class);
Inject inject = setUpInject("DEST_FILE_ABS_PATH", temporaryFile, destinationFileReader, tmpFileWriter, setUpContent("CONTENT_ID", contentFile));
inject.setContentConverter("unknown");
injects.add(inject);
given(ioFactory.createTemporaryFile(inject.getDestinationFile())).willReturn(temporaryFile);
given(destinationFileReader.readLine()).willReturn("${inject.content.CONTENT_ID}").willReturn(null);
//When
try {
injectContent.execute();
} catch (MojoExecutionException e) {
//Then
verify(destinationFileReader).close();
verify(tmpFileWriter).flush();
verify(tmpFileWriter).close();
throw e;
}
}
use of org.apache.maven.plugin.MojoExecutionException in project intellij-community by JetBrains.
the class MavenEffectivePomDumper method writeEffectivePom.
/**
* org.apache.maven.plugins.help.EffectivePomMojo#writeEffectivePom
*/
private static void writeEffectivePom(MavenProject project, XMLWriter writer) throws MojoExecutionException {
Model pom = project.getModel();
cleanModel(pom);
String effectivePom;
StringWriter sWriter = new StringWriter();
MavenXpp3Writer pomWriter = new MavenXpp3Writer();
try {
pomWriter.write(sWriter, pom);
} catch (IOException e) {
throw new MojoExecutionException("Cannot serialize POM to XML.", e);
}
effectivePom = addMavenNamespace(sWriter.toString(), true);
writeComment(writer, "Effective POM for project \'" + project.getId() + "\'");
writer.writeMarkup(effectivePom);
}
use of org.apache.maven.plugin.MojoExecutionException in project jangaroo-tools by CoreMedia.
the class PomConverter method changePackaging.
/**
* Changes the packaging from jangaroo to jangaroo-pkg in {@code /project/packaging}
*/
private static void changePackaging(Document document) throws MojoExecutionException {
try {
XPathFactory xPathFactory = XPathFactory.newInstance();
XPath xPath = xPathFactory.newXPath();
Node packagingNode = (Node) xPath.evaluate("/project/packaging[text() = 'jangaroo']", document, NODE);
if (packagingNode != null) {
packagingNode.setTextContent("jangaroo-pkg");
}
} catch (XPathException e) {
throw new MojoExecutionException("error while generating modified POM", e);
}
}
Aggregations