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

org.codehaus.mojo.natives.util.CommandLineUtil Maven / Gradle / Ivy

There is a newer version: 1.0-M1
Show newest version
package org.codehaus.mojo.natives.util;

import org.codehaus.mojo.natives.NativeBuildException;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
import org.codehaus.plexus.util.cli.DefaultConsumer;
import org.codehaus.plexus.logging.Logger;

public class CommandLineUtil 
{
	public static void execute( Commandline cl, Logger logger ) 
		throws NativeBuildException
	{
		int ok;
		
		try 
		{
			DefaultConsumer stdout = new DefaultConsumer();

			DefaultConsumer stderr = stdout;
			
			logger.info( cl.toString() );
			
			ok = CommandLineUtils.executeCommandLine( cl, stdout, stderr );
		}
		catch ( CommandLineException ecx) 
		{
			throw new NativeBuildException( "Error executing command line", ecx );
		}
        
		if ( ok != 0 )
		{
			throw new NativeBuildException( "Error executing command line. Exit code:" + ok );
		}		
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy