Search in sources :

Example 1 with MojoFailureException

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);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 2 with MojoFailureException

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);
}
Also used : Field(java.lang.reflect.Field) PrintStream(java.io.PrintStream) MojoFailureException(org.apache.maven.plugin.MojoFailureException) Resource(org.apache.maven.model.Resource) DefinitionClassInfo(com.sun.identity.cli.annotation.DefinitionClassInfo) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 3 with MojoFailureException

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);
        }
    }
}
Also used : MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 4 with MojoFailureException

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);
    }
}
Also used : File(java.io.File) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 5 with MojoFailureException

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.'");
        }
    }
}
Also used : MojoFailureException(org.apache.maven.plugin.MojoFailureException) File(java.io.File)

Aggregations

MojoFailureException (org.apache.maven.plugin.MojoFailureException)367 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)201 File (java.io.File)190 IOException (java.io.IOException)165 ArrayList (java.util.ArrayList)89 MavenProject (org.apache.maven.project.MavenProject)49 FileInputStream (java.io.FileInputStream)37 TreeSet (java.util.TreeSet)35 Artifact (org.apache.maven.artifact.Artifact)33 FileOutputStream (java.io.FileOutputStream)32 List (java.util.List)32 Map (java.util.Map)28 MalformedURLException (java.net.MalformedURLException)27 URLClassLoader (java.net.URLClassLoader)27 URL (java.net.URL)24 HashMap (java.util.HashMap)23 AbstractMojo (org.apache.maven.plugin.AbstractMojo)20 Set (java.util.Set)19 Path (java.nio.file.Path)18 HashSet (java.util.HashSet)17