Search in sources :

Example 76 with MojoExecutionException

use of org.apache.maven.plugin.MojoExecutionException in project liquibase by liquibase.

the class LiquibaseRollbackSQL method createLiquibase.

@Override
protected Liquibase createLiquibase(ResourceAccessor fo, Database db) throws MojoExecutionException {
    Liquibase liquibase = super.createLiquibase(fo, db);
    // Setup the output file writer
    try {
        if (!migrationSqlOutputFile.exists()) {
            // Ensure the parent directories exist
            migrationSqlOutputFile.getParentFile().mkdirs();
            // Create the actual file
            if (!migrationSqlOutputFile.createNewFile()) {
                throw new MojoExecutionException("Cannot create the migration SQL file; " + migrationSqlOutputFile.getAbsolutePath());
            }
        }
        outputWriter = getOutputWriter(migrationSqlOutputFile);
    } catch (IOException e) {
        getLog().error(e);
        throw new MojoExecutionException("Failed to create SQL output writer", e);
    }
    getLog().info("Output SQL Migration File: " + migrationSqlOutputFile.getAbsolutePath());
    return liquibase;
}
Also used : Liquibase(liquibase.Liquibase) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException)

Example 77 with MojoExecutionException

use of org.apache.maven.plugin.MojoExecutionException in project wire by square.

the class WireGenerateSourcesMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    // Add the directory into which generated sources are placed as a compiled source root.
    project.addCompileSourceRoot(generatedSourceDirectory);
    try {
        List<String> directories = protoPaths != null && protoPaths.length > 0 ? Arrays.asList(protoPaths) : Collections.singletonList(protoSourceDirectory);
        List<String> protoFilesList = Arrays.asList(protoFiles);
        Schema schema = loadSchema(directories, protoFilesList);
        Profile profile = loadProfile(schema);
        IdentifierSet identifierSet = identifierSet();
        if (!identifierSet.isEmpty()) {
            schema = retainRoots(identifierSet, schema);
        }
        JavaGenerator javaGenerator = JavaGenerator.get(schema).withAndroid(emitAndroid).withCompact(emitCompact).withProfile(profile);
        for (ProtoFile protoFile : schema.protoFiles()) {
            if (!protoFilesList.isEmpty() && !protoFilesList.contains(protoFile.location().path())) {
                // Don't emit anything for files not explicitly compiled.
                continue;
            }
            for (Type type : protoFile.types()) {
                Stopwatch stopwatch = Stopwatch.createStarted();
                TypeSpec typeSpec = javaGenerator.generateType(type);
                ClassName javaTypeName = javaGenerator.generatedTypeName(type);
                writeJavaFile(javaTypeName, typeSpec, type.location().withPathOnly());
                getLog().info(String.format("Generated %s in %s", javaTypeName, stopwatch));
            }
        }
    } catch (Exception e) {
        throw new MojoExecutionException("Wire Plugin: Failure compiling proto sources.", e);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Schema(com.squareup.wire.schema.Schema) ProtoFile(com.squareup.wire.schema.ProtoFile) Stopwatch(com.google.common.base.Stopwatch) JavaGenerator(com.squareup.wire.java.JavaGenerator) IdentifierSet(com.squareup.wire.schema.IdentifierSet) Profile(com.squareup.wire.java.Profile) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) Type(com.squareup.wire.schema.Type) ClassName(com.squareup.javapoet.ClassName) TypeSpec(com.squareup.javapoet.TypeSpec)

Example 78 with MojoExecutionException

use of org.apache.maven.plugin.MojoExecutionException in project wire by square.

the class CodegenSampleMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    project.addCompileSourceRoot(generatedSourceDirectory);
    ImmutableSet<String> protoPathsSet = ImmutableSet.copyOf(protoPaths);
    ImmutableSet<String> protoFilesSet = ImmutableSet.copyOf(protoFiles);
    IdentifierSet identifierSet = identifierSet();
    try {
        CodegenSample codeGenerator = new CodegenSample(this, protoPathsSet, protoFilesSet, generatedSourceDirectory, identifierSet);
        codeGenerator.execute();
    } catch (IOException e) {
        throw new MojoExecutionException("failed to generate sources", e);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException) IdentifierSet(com.squareup.wire.schema.IdentifierSet)

Example 79 with MojoExecutionException

use of org.apache.maven.plugin.MojoExecutionException in project saga by timurstrekalov.

the class SagaMojo method execute.

@Override
public void execute() throws MojoExecutionException {
    if (skipTests) {
        getLog().info("Coverage reporting is skipped.");
        return;
    }
    try {
        final CoverageGenerator gen = CoverageGeneratorFactory.newInstance(baseDir, outputDir);
        final Config config = gen.getConfig();
        config.setIncludes(includes);
        config.setExcludes(excludes);
        config.setOutputInstrumentedFiles(outputInstrumentedFiles);
        config.setCacheInstrumentedCode(cacheInstrumentedCode);
        config.setNoInstrumentPatterns(noInstrumentPatterns);
        config.setOutputStrategy(outputStrategy);
        config.setThreadCount(threadCount);
        config.setIncludeInlineScripts(includeInlineScripts);
        config.setBackgroundJavaScriptTimeout(backgroundJavaScriptTimeout);
        config.setSourcesToPreload(sourcesToPreload);
        config.setSourcesToPreloadEncoding(sourcesToPreloadEncoding);
        config.setBrowserVersion(browserVersion);
        config.setReportFormats(reportFormats);
        config.setSortBy(sortBy);
        config.setOrder(order);
        config.setWebDriverCapabilities(webDriverCapabilities);
        config.setWebDriverClassName(webDriverClassName);
        if (sourceDirs == null) {
            sourceDirs = Lists.newArrayList(defaultSourceDir);
        } else if (sourceDirs.isEmpty()) {
            sourceDirs.add(defaultSourceDir);
        }
        config.setSourceDir(sourceDirs);
        gen.instrumentAndGenerateReports();
    } catch (final IllegalArgumentException e) {
        throw new MojoExecutionException("Caught IllegalArgumentException: illegal parameters?", e);
    } catch (final Exception e) {
        throw new MojoExecutionException("Error generating coverage", e);
    }
}
Also used : CoverageGenerator(com.github.timurstrekalov.saga.core.CoverageGenerator) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Config(com.github.timurstrekalov.saga.core.cfg.Config) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException)

Example 80 with MojoExecutionException

use of org.apache.maven.plugin.MojoExecutionException in project yeoman-maven-plugin by trecloux.

the class YeomanMojo method executeCommand.

void executeCommand(String command) throws MojoExecutionException {
    try {
        if (isWindows()) {
            command = "cmd /c " + command;
        }
        CommandLine cmdLine = CommandLine.parse(command);
        DefaultExecutor executor = new DefaultExecutor();
        executor.setWorkingDirectory(yeomanProjectDirectory);
        executor.execute(cmdLine);
    } catch (IOException e) {
        throw new MojoExecutionException("Error during : " + command, e);
    }
}
Also used : CommandLine(org.apache.commons.exec.CommandLine) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) DefaultExecutor(org.apache.commons.exec.DefaultExecutor) IOException(java.io.IOException)

Aggregations

MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)586 IOException (java.io.IOException)322 File (java.io.File)261 MojoFailureException (org.apache.maven.plugin.MojoFailureException)138 Artifact (org.apache.maven.artifact.Artifact)86 ArrayList (java.util.ArrayList)70 FileInputStream (java.io.FileInputStream)56 HashMap (java.util.HashMap)47 MavenProject (org.apache.maven.project.MavenProject)37 MalformedURLException (java.net.MalformedURLException)34 Map (java.util.Map)34 ArchiverException (org.codehaus.plexus.archiver.ArchiverException)32 Properties (java.util.Properties)30 FileOutputStream (java.io.FileOutputStream)28 FileWriter (java.io.FileWriter)28 List (java.util.List)25 URL (java.net.URL)22 InputStream (java.io.InputStream)21 LinkedHashSet (java.util.LinkedHashSet)21 FileNotFoundException (java.io.FileNotFoundException)20