com.tpspay.postmaven.postbuild.PostSourceMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of postbuild-maven-plugin Show documentation
Show all versions of postbuild-maven-plugin Show documentation
A maven build plugin for building Postilion nodes.
The newest version!
package com.tpspay.postmaven.postbuild;
import java.io.File;
import java.io.IOException;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
/**
* Build all Postilion source files
*
* @goal post-source
*
* @phase generate-sources
*
* @author John Oxley <[email protected]>
*/
public class PostSourceMojo extends AbstractPostilionBuildMojo {
public void execute() throws MojoExecutionException, MojoFailureException {
try {
if (!new File(buildGeneratedFile).exists()) {
throw new MojoExecutionException("Object file does not exist " + buildGeneratedFile);
}
CommandLine line = new CommandLine("python");
line.addArgument(buildGeneratedFile);
line.addArgument("java");
getLog().info(line.toString());
DefaultExecutor executor = new DefaultExecutor();
int exitValue = executor.execute(line);
if (exitValue != 0) {
throw new MojoExecutionException("Problem executing build java, return code " + exitValue);
}
} catch (ExecuteException e) {
throw new MojoExecutionException("Problem executing build java", e);
} catch (IOException e) {
throw new MojoExecutionException("Problem executing build java", e);
}
}
}