Package org.apache.maven.plugin

Examples of org.apache.maven.plugin.MojoExecutionException


                this.archive);
            artifact.setFile(cartridgeFile);
        }
        catch (final Throwable throwable)
        {
            throw new MojoExecutionException("An error occured while packaging this cartridge", throwable);
        }
    }
View Full Code Here


        if (!this.skip)
        {
            final File expectedOutputArchive = new File(this.expectedOutputArchive);
            if (!expectedOutputArchive.exists() || !expectedOutputArchive.isFile())
            {
                throw new MojoExecutionException("The path specifying the expectedOutputArchive '" +
                    this.expectedOutputArchive + "' must be a file");
            }

            try
            {
                this.getLog().info("-----------------------------------------------------------------------------");
                this.getLog().info("          A n d r o M D A   C a r t r i d g e   T e s t   S u i t e          ");
                this.getLog().info("-----------------------------------------------------------------------------");

                // - add the cartridge test dependencies (any dependencies of the cartridge test plugin)
                this.addCartridgeTestDependencies();

                // - first run AndroMDA with the test configuration
                final AndroMDAMojo andromdaMojo = new AndroMDAMojo();
                andromdaMojo.setConfigurationUri(this.configurationUri);
                andromdaMojo.setProject(this.project);
                andromdaMojo.setSettings(this.settings);
                andromdaMojo.setPropertyFiles(this.propertyFiles);
                andromdaMojo.execute();

                // - unpack the expected output archive
                this.unpack(
                    expectedOutputArchive,
                    new File(this.expectedDirectory));

                final CartridgeTest cartridgeTest = CartridgeTest.instance();
                cartridgeTest.setActualOutputPath(this.actualDirectory);
                cartridgeTest.setExpectedOutputPath(this.expectedDirectory);
                cartridgeTest.setBinarySuffixes(this.binaryOutputSuffixes);

                final CartridgeTestFormatter formatter = new CartridgeTestFormatter();

                // - set the report location
                final File report = new File(this.reportDirectory, this.project.getArtifactId() + ".txt");
                formatter.setReportFile(report);
                final TestResult result = new TestResult();
                result.addListener(formatter);
                final Test suite = CartridgeTest.suite();
                formatter.startTestSuite(this.project.getName());
                suite.run(result);
                this.getLog().info("");
                this.getLog().info("Results:");
                this.getLog().info(formatter.endTestSuite(suite));
                cartridgeTest.shutdown();
                if (result.failureCount() > 0 || result.errorCount() > 0)
                {
                    throw new MojoExecutionException("Test are some test failures");
                }
            }
            catch (final Throwable throwable)
            {
                if (throwable instanceof MojoExecutionException)
                {
                    throw (MojoExecutionException)throwable;
                }
                throw new MojoExecutionException("An error occured while testing cartridge '" +
                    this.project.getArtifactId() + "'",
                    ExceptionUtils.getRootCause(throwable));
            }
        }
        else
View Full Code Here

        }
        catch (Throwable throwable)
        {
            if (throwable instanceof IOException || throwable instanceof ArchiverException)
            {
                throw new MojoExecutionException("Error unpacking file: " + file + "to: " + location, throwable);
            }
        }
    }
View Full Code Here

                new ArrayList());
            project.addCompileSourceRoot(this.buildSourceDirectory);
        }
        catch (Throwable throwable)
        {
            throw new MojoExecutionException("An error occurred while attempting to process SableCC grammar(s)",
                throwable);
        }
    }
View Full Code Here

        try
        {
            final URL configurationUri = ResourceUtils.toURL(this.configurationUri);
            if (configurationUri == null)
            {
                throw new MojoExecutionException("Configuration could not be loaded from '" + this.configurationUri +
                    "'");
            }
            final Configuration configuration = this.getConfiguration(configurationUri);
            boolean execute = true;
            if (this.lastModifiedCheck)
            {
                final File directory = new File(this.buildSourceDirectory);
                execute = ResourceUtils.modifiedAfter(
                        ResourceUtils.getLastModifiedTime(configurationUri),
                        directory);
                if (!execute)
                {
                    final Repository[] repositories = configuration.getRepositories();
                    int repositoryCount = repositories.length;
                    for (int ctr = 0; ctr < repositoryCount; ctr++)
                    {
                        final Repository repository = repositories[ctr];
                        if (repository != null)
                        {
                            final Model[] models = repository.getModels();
                            final int modelCount = models.length;
                            for (int ctr2 = 0; ctr2 < modelCount; ctr2++)
                            {
                                final Model model = models[ctr2];
                                execute = ResourceUtils.modifiedAfter(
                                        model.getLastModified(),
                                        directory);
                                if (execute)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            if (execute)
            {
                this.initializeClasspathFromClassPathElements(this.project.getRuntimeClasspathElements());
                final AndroMDA andromda = AndroMDA.newInstance();
                andromda.run(configuration);
                andromda.shutdown();
            }
            else
            {
                this.getLog().info("Files are up-to-date, skipping AndroMDA execution");
            }
            final File buildSourceDirectory =
                this.buildSourceDirectory != null ? new File(this.buildSourceDirectory) : null;
            if (buildSourceDirectory != null)
            {
                this.getProject().addCompileSourceRoot(buildSourceDirectory.toString());
            }
        }
        catch (Throwable throwable)
        {
            String message = "Error running AndroMDA";
            throwable = ExceptionUtils.getRootCause(throwable);
            if (throwable instanceof MalformedURLException || throwable instanceof FileNotFoundException)
            {
                message = "Configuration is not valid '" + this.configurationUri + "'";
            }
            throw new MojoExecutionException(message, throwable);
        }
    }
View Full Code Here

                processor.setUseTraceTranslator(this.traceExpression);
                processor.setTestSourceDirectory(this.testSourceDirectory);
                final URL configurationUri = ResourceUtils.toURL(this.configurationUri);
                if (configurationUri == null)
                {
                    throw new MojoExecutionException("No configuration could be loaded from --> '" +
                        this.configurationUri + "'");
                }
                processor.setConfiguration(this.getConfiguration(configurationUri));

                final TranslationLibraryTestFormatter formatter = new TranslationLibraryTestFormatter();

                // - set the report location
                final File report = new File(this.reportDirectory, this.getProject().getArtifactId() + ".txt");
                formatter.setReportFile(report);
                final TestResult result = new TestResult();
                formatter.startTestSuite(this.getProject().getName());
                result.addListener(formatter);
                processor.setResult(result);
                processor.runSuite();
                this.getLog().info("");
                this.getLog().info("Results:");
                this.getLog().info(formatter.endTestSuite());
                if (result.failureCount() > 0 || result.errorCount() > 0)
                {
                    throw new MojoExecutionException("Test are some test failures");
                }
                processor.shutdown();
            }
            catch (final Throwable throwable)
            {
                if (throwable instanceof MojoExecutionException)
                {
                    throw (MojoExecutionException)throwable;
                }
                throw new MojoExecutionException("An error occured while testing translation-library",
                    ExceptionUtils.getRootCause(throwable));
            }
        }
        else
        {
View Full Code Here

            // - set the artifact file back to the correct file (since we've installed modelJar already)
            artifact.setFile(uml2File);
        }
        catch (final Throwable throwable)
        {
            throw new MojoExecutionException("Error assembling model", throwable);
        }
    }
View Full Code Here

        {
            if (throwable instanceof MojoExecutionException)
            {
                throw (MojoExecutionException)throwable;
            }
            throw new MojoExecutionException("An error occured while updating cartridge archive '"
                    + this.project.getArtifactId() + "'", ExceptionUtils.getRootCause(throwable));
        }

    }
View Full Code Here

        }
        catch (Throwable throwable)
        {
            if (throwable instanceof IOException || throwable instanceof ArchiverException)
            {
                throw new MojoExecutionException("Error packing directory: " + location + "to: " + file, throwable);
            }
        }
    }
View Full Code Here

                            }
                        }
                    }
                    catch (final Throwable throwable)
                    {
                        throw new MojoExecutionException("An error occurred while attempting to deploy artifact",
                            throwable);
                    }
                }
                else
                {
View Full Code Here

TOP

Related Classes of org.apache.maven.plugin.MojoExecutionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.