use of org.apache.maven.plugin.MojoFailureException in project jetty.project by eclipse.
the class JspcMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
if (getLog().isDebugEnabled()) {
getLog().info("webAppSourceDirectory=" + webAppSourceDirectory);
getLog().info("generatedClasses=" + generatedClasses);
getLog().info("webXmlFragment=" + webXmlFragment);
getLog().info("webXml=" + webXml);
getLog().info("insertionMarker=" + (insertionMarker == null || insertionMarker.equals("") ? END_OF_WEBAPP : insertionMarker));
getLog().info("keepSources=" + keepSources);
getLog().info("mergeFragment=" + mergeFragment);
if (sourceVersion != null)
getLog().info("sourceVersion=" + sourceVersion);
if (targetVersion != null)
getLog().info("targetVersion=" + targetVersion);
}
try {
prepare();
compile();
cleanupSrcs();
mergeWebXml();
} catch (Exception e) {
throw new MojoExecutionException("Failure processing jsps", e);
}
}
use of org.apache.maven.plugin.MojoFailureException 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.MojoFailureException in project OpenAM by OpenRock.
the class CLIDefinitionGenerator method validateOption.
private void validateOption(List<String> options) throws MojoFailureException {
for (String option : options) {
int idx = option.indexOf('|');
String longName = option.substring(0, idx);
String shortName = option.substring(idx + 1, idx + 2);
String test = mapLongToShortOptionName.get(longName);
if (test == null) {
mapLongToShortOptionName.put(longName, shortName);
} else if (!test.equals(shortName)) {
throw new MojoFailureException("Mismatched names: " + longName + "-> " + test + ", " + shortName);
}
}
}
use of org.apache.maven.plugin.MojoFailureException in project maven-plugins by apache.
the class PmdViolationCheckMojoTest method testDefaultConfiguration.
public void testDefaultConfiguration() throws Exception {
try {
final File testPom = new File(getBasedir(), "src/test/resources/unit/default-configuration/pmd-check-default-configuration-plugin-config.xml");
final PmdViolationCheckMojo mojo = (PmdViolationCheckMojo) lookupMojo("check", testPom);
mojo.execute();
fail("MojoFailureException should be thrown.");
} catch (final Exception e) {
assertTrue(true);
}
}
use of org.apache.maven.plugin.MojoFailureException in project maven-plugins by apache.
the class PmdViolationCheckMojoTest method testFailurePriority.
public void testFailurePriority() throws Exception {
File testPom = new File(getBasedir(), "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml");
final PmdReport mojo = (PmdReport) lookupMojo("pmd", testPom);
mojo.execute();
testPom = new File(getBasedir(), "src/test/resources/unit/default-configuration/pmd-check-failonpriority-plugin-config.xml");
PmdViolationCheckMojo pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo("check", testPom);
pmdViolationMojo.execute();
testPom = new File(getBasedir(), "src/test/resources/unit/default-configuration/pmd-check-failandwarnonpriority-plugin-config.xml");
pmdViolationMojo = (PmdViolationCheckMojo) lookupMojo("check", testPom);
try {
pmdViolationMojo.execute();
fail("Exception Expected");
} catch (final MojoFailureException e) {
String message = e.getMessage();
if (message.contains("You have 5 PMD violations and 3 warnings.")) {
// expected
System.out.println("Caught expected message: " + e.getMessage());
} else {
throw new AssertionError("Expected: '" + message + "' to contain 'You have 5 PMD violations and 3 warnings.'");
}
}
}
Aggregations