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

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

There is a newer version: 1.0.1
Show 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;

/**
 * Goal which calls build all on the generated build.py
 * 
 * @goal post-all
 * 
 * @phase package
 * 
 * @author John Oxley <[email protected]>
 */
public class PostAllMojo 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("all");
			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 - 2025 Weber Informatics LLC | Privacy Policy