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;
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations