Search in sources :

Example 26 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 27 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 28 with MojoFailureException

use of org.apache.maven.plugin.MojoFailureException in project jangaroo-tools by CoreMedia.

the class JooTestMojo method execute.

public void execute() throws MojoExecutionException, MojoFailureException {
    if (!skip && !skipTests && !skipJooUnitTests && isTestAvailable()) {
        Server server = jettyRunTest(true);
        String url = getTestUrl(server);
        try {
            File testResultOutputFile = new File(testResultOutputDirectory, getTestResultFileName());
            File phantomTestRunner = new File(testResultOutputDirectory, "phantomjs-joounit-page-runner.js");
            FileUtils.copyInputStreamToFile(getClass().getResourceAsStream("/net/jangaroo/jooc/mvnplugin/phantomjs-joounit-page-runner.js"), phantomTestRunner);
            final PhantomJsTestRunner phantomJsTestRunner = new PhantomJsTestRunner(phantomBin, url, testResultOutputFile.getPath(), phantomTestRunner.getPath(), jooUnitTestExecutionTimeout, jooUnitMaxRetriesOnCrashes, getLog());
            if (phantomJsTestRunner.canRun()) {
                executePhantomJs(testResultOutputFile, phantomJsTestRunner);
            } else {
                executeSelenium(url);
            }
        } catch (IOException e) {
            throw new MojoExecutionException("Cannot create local copy of phantomjs-joounit-page-runner.js", e);
        } finally {
            try {
                server.stop();
            } catch (Exception e) {
                // never mind we just couldn't step the selenium server.
                getLog().error("Could not stop test Jetty.", e);
            }
        }
    }
}
Also used : Server(org.eclipse.jetty.server.Server) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException) File(java.io.File) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) UnknownHostException(java.net.UnknownHostException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) SeleniumException(com.thoughtworks.selenium.SeleniumException)

Example 29 with MojoFailureException

use of org.apache.maven.plugin.MojoFailureException in project jangaroo-tools by CoreMedia.

the class JooTestMojoTest method testEvalTestOutputFailure.

public void testEvalTestOutputFailure() throws MojoExecutionException, MojoFailureException, IOException, SAXException, ParserConfigurationException {
    String testResult = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n" + "<testsuite errors=\"0\" failures=\"1\" name=\"com.coremedia.ui.data::BeanImplTest\" tests=\"21\" time=\"2814\"></testsuite>";
    try {
        jooTestMojo.evalTestOutput(new StringReader(testResult));
    } catch (MojoFailureException e) {
        return;
    }
    fail("Should reach that point (testing for exception)");
}
Also used : StringReader(java.io.StringReader) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 30 with MojoFailureException

use of org.apache.maven.plugin.MojoFailureException in project aries by apache.

the class GenerateMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    List<String> toScan = getPackagesToScan();
    if (!sourcesChanged()) {
        getLog().info("Skipping blueprint generation because source files were not changed");
        return;
    }
    BlueprintConfigurationImpl blueprintConfiguration = new BlueprintConfigurationImpl(namespaces, defaultActivation, customParameters);
    try {
        ClassFinder classFinder = createProjectScopeFinder();
        Set<Class<?>> classes = FilteredClassFinder.findClasses(classFinder, toScan);
        Blueprint blueprint = new Blueprint(blueprintConfiguration, classes);
        writeBlueprintIfNeeded(blueprint);
    } catch (Exception e) {
        throw new MojoExecutionException("Error building commands help", e);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Blueprint(org.apache.aries.blueprint.plugin.model.Blueprint) ClassFinder(org.apache.xbean.finder.ClassFinder) MalformedURLException(java.net.MalformedURLException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Aggregations

MojoFailureException (org.apache.maven.plugin.MojoFailureException)157 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)94 File (java.io.File)93 IOException (java.io.IOException)91 ArrayList (java.util.ArrayList)50 TreeSet (java.util.TreeSet)33 FileInputStream (java.io.FileInputStream)32 FileOutputStream (java.io.FileOutputStream)21 List (java.util.List)21 Map (java.util.Map)21 MavenProject (org.apache.maven.project.MavenProject)18 Set (java.util.Set)15 MalformedURLException (java.net.MalformedURLException)14 HashMap (java.util.HashMap)13 HashSet (java.util.HashSet)13 InputStream (java.io.InputStream)12 URLClassLoader (java.net.URLClassLoader)12 Matcher (java.util.regex.Matcher)12 Artifact (org.apache.maven.artifact.Artifact)12 AbstractMojo (org.apache.maven.plugin.AbstractMojo)12