All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tpspay.postmaven.postbuild.PostSourceMojo Maven / Gradle / Ivy

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy