本文整理汇总了Java中org.codehaus.plexus.util.cli.Commandline类的典型用法代码示例。如果您正苦于以下问题:Java Commandline类的具体用法?Java Commandline怎么用?Java Commandline使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Commandline类属于org.codehaus.plexus.util.cli包,在下文中一共展示了Commandline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEndOptions
import org.codehaus.plexus.util.cli.Commandline; //导入依赖的package包/类
public void testEndOptions()
throws Exception {
File[] includePaths = {new File("p1"), new File("p2")};
config.setIncludePaths(includePaths);
String[] startOptions = {"-s1", "-s2"};
String[] middleOptions = {"-m1", "-m2"};
String[] endOptions = {"-e1", "-e2"};
config.setStartOptions(startOptions);
config.setMiddleOptions(middleOptions);
config.setEndOptions(endOptions);
Commandline cl = compiler.getCommandLine(sourceFile, objectFile, config);
assertArrayEquals(new String[]{"gcc", "-s1", "-s2", "-Ip1", "-Ip2", "-m1", "-m2", simpleArgv[0], simpleArgv[1], simpleArgv[2], simpleArgv[3], "-e1", "-e2"}, cl.getCommandline());
}
示例2: testEndOptions
import org.codehaus.plexus.util.cli.Commandline; //导入依赖的package包/类
public void testEndOptions()
throws Exception
{
File[] includePaths = { new File( "p1" ), new File( "p2" ) };
config.setIncludePaths( includePaths );
String[] startOptions = { "-s1", "-s2" };
String[] middleOptions = { "-m1", "-m2" };
String[] endOptions = { "-e1", "-e2" };
config.setStartOptions( startOptions );
config.setMiddleOptions( middleOptions );
config.setEndOptions( endOptions );
Commandline cl = compiler.getCommandLine( sourceFile, objectFile, config );
assertArrayEquals(new String[] {"gcc", "-s1", "-s2", "-Ip1" ,"-Ip2", "-m1", "-m2", simpleArgv[0], simpleArgv[1], simpleArgv[2], simpleArgv[3], "-e1", "-e2"}, cl.getCommandline() );
}
示例3: setupCommandlineEnv
import org.codehaus.plexus.util.cli.Commandline; //导入依赖的package包/类
public static void setupCommandlineEnv( Commandline cl, EnvFactory envFactory )
throws NativeBuildException
{
if ( envFactory != null )
{
Map envs = envFactory.getEnvironmentVariables();
Iterator iter = envs.keySet().iterator();
while ( iter.hasNext() )
{
String key = (String) iter.next();
cl.addEnvironment( key, (String) envs.get( key ) );
}
}
}
示例4: execute
import org.codehaus.plexus.util.cli.Commandline; //导入依赖的package包/类
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 );
}
}
示例5: execute
import org.codehaus.plexus.util.cli.Commandline; //导入依赖的package包/类
private void execute(Commandline jDepsCommand) throws CommandLineException {
StringStreamConsumer errorConsoleConsumer = new StringStreamConsumer();
MojoLogging.logger().debug(format("Running JDeps: %s", jDepsCommand));
MojoLogging.logger().debug(String.format(
"(JDeps output is forwarded here. "
+ "Lines are marked: %s = recognized as dependency; %s = not recognized.)",
ViolationParser.MESSAGE_MARKER_JDEPS_LINE,
ViolationParser.MESSAGE_MARKER_UNKNOWN_LINE));
int exitCode = CommandLineUtils.executeCommandLine(
jDepsCommand, jDepsOutputConsumer::accept, errorConsoleConsumer);
MojoLogging.logger().debug(format("JDeps completed with exit code %d.", exitCode));
if (exitCode != 0)
throwCommandLineException(jDepsCommand, exitCode, errorConsoleConsumer.getOutput());
}
示例6: isSvn18
import org.codehaus.plexus.util.cli.Commandline; //导入依赖的package包/类
private static boolean isSvn18()
{
Commandline cl = new Commandline();
cl.setExecutable( "svn" );
StringStreamConsumer stdout = new StringStreamConsumer();
StringStreamConsumer stderr = new StringStreamConsumer();
try
{
CommandLineUtils.executeCommandLine( cl, stdout, stderr );
return stdout.getOutput().contains( "svn, version 1.8." );
}
catch ( CommandLineException e )
{
}
return false;
}
示例7: getDotExecutable
import org.codehaus.plexus.util.cli.Commandline; //导入依赖的package包/类
private static String getDotExecutable() {
Commandline cmd = new Commandline();
String finderExecutable = isWindows() ? "where.exe" : "which";
cmd.setExecutable(finderExecutable);
cmd.addArguments(new String[]{"dot"});
CommandLineUtils.StringStreamConsumer systemOut = new CommandLineUtils.StringStreamConsumer();
CommandLineUtils.StringStreamConsumer systemErr = new CommandLineUtils.StringStreamConsumer();
try {
int exitCode = CommandLineUtils.executeCommandLine(cmd, systemOut, systemErr);
if (exitCode != 0) {
return null;
}
} catch (CommandLineException e) {
return null;
}
return systemOut.getOutput();
}
示例8: start
import org.codehaus.plexus.util.cli.Commandline; //导入依赖的package包/类
public Process start() throws ExecutionException {
Commandline commandline = getCommandLine();
String[] shellCommandline = commandline.getShellCommandline();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(PHANTOMJS_COMMAND, Arrays.asList(shellCommandline));
}
ProcessBuilder processBuilder = new ProcessBuilder(shellCommandline);
if (commandline.getWorkingDirectory() != null) {
processBuilder.directory(commandline.getWorkingDirectory());
}
try {
return processBuilder.start();
} catch(IOException e) {
throw new ExecutionException(UNABLE_TO_START,e);
}
}
示例9: getCommandLine
import org.codehaus.plexus.util.cli.Commandline; //导入依赖的package包/类
private Commandline getCommandLine() throws ExecutionException {
Commandline commandline = new Commandline(this.phantomJsBinary);
if (configFile != null && configFile.exists()) {
commandline.createArg().setValue("--config=" + configFile.getAbsolutePath());
} else {
commandline.addArguments(this.getCommandLineOptions(commandLineOptions));
}
if (script != null) {
commandline.createArg().setValue(script);
}
if (arguments != null) {
commandline.addArguments(arguments.toArray(new String[arguments.size()]));
}
if (workingDirectory != null) {
commandline.setWorkingDirectory(workingDirectory);
}
return commandline;
}
示例10: prepareModeSpecificCommandLineArguments
import org.codehaus.plexus.util.cli.Commandline; //导入依赖的package包/类
/**
* Method to add on any additional command line arguments for this mode of invoking the
* DataNucleus Enhancer.
* @param cl The current CommandLine
* @param args Args that will be updated with anything appended here
*/
protected void prepareModeSpecificCommandLineArguments(Commandline cl, List args)
{
if (targetDirectory != null && targetDirectory.trim().length() > 0)
{
// Output the enhanced classes to a different location
if (fork)
{
cl.createArg().setValue("-d");
cl.createArg().setValue(targetDirectory);
}
else
{
args.add("-d");
args.add(targetDirectory);
}
}
}
示例11: createJDepsCommand
import org.codehaus.plexus.util.cli.Commandline; //导入依赖的package包/类
private Commandline createJDepsCommand(Path jDepsExecutable) {
Commandline jDepsCommand = new Commandline();
jDepsCommand.setExecutable(jDepsExecutable.toAbsolutePath().toString());
jDepsCommand.createArg().setValue("-jdkinternals");
jDepsCommand.createArg().setFile(artifactToAnalyze.toFile());
return jDepsCommand;
}
示例12: execute
import org.codehaus.plexus.util.cli.Commandline; //导入依赖的package包/类
private void execute(Commandline jDepsCommand) throws CommandLineException {
StringStreamConsumer errorConsoleConsumer = new StringStreamConsumer();
int exitCode = CommandLineUtils.executeCommandLine(
jDepsCommand, jDepsOutputConsumer::accept, errorConsoleConsumer);
if (exitCode != 0)
throwCommandLineException(jDepsCommand, exitCode, errorConsoleConsumer.getOutput());
}
示例13: throwCommandLineException
import org.codehaus.plexus.util.cli.Commandline; //导入依赖的package包/类
private static void throwCommandLineException(Commandline jDepsCommand, int exitCode, String errorOutput)
throws CommandLineException {
StringBuilder message = new StringBuilder("JDeps returned with exit code '" + exitCode + "'.\n");
message.append("\t Executed command: "
+ CommandLineUtils.toString(jDepsCommand.getCommandline()).replaceAll("'", ""));
message.append("\t Error output:\n");
streamLines(errorOutput).forEachOrdered(errorLine -> message.append("\t\t " + errorLine + "\n"));
throw new CommandLineException(message.toString());
}
示例14: getCommandLine
import org.codehaus.plexus.util.cli.Commandline; //导入依赖的package包/类
protected Commandline getCommandLine( File src, File dest, CompilerConfiguration config )
throws NativeBuildException
{
if ( config.getExecutable() == null || config.getExecutable().trim().length() == 0 )
{
config.setExecutable( "bcc32" );
}
Commandline cl = super.getCommandLine( src, dest, config );
return cl;
}
示例15: createLinkerCommandLine
import org.codehaus.plexus.util.cli.Commandline; //导入依赖的package包/类
protected Commandline createLinkerCommandLine( List objectFiles, LinkerConfiguration config )
throws NativeBuildException
{
Commandline cl = new Commandline();
cl.setWorkingDirectory( config.getWorkingDirectory().getPath() );
String executable = EXECUTABLE;
if ( config.getExecutable() != null && config.getExecutable().trim().length() != 0 )
{
executable = config.getExecutable();
}
cl.createArg().setValue( executable );
cl.createArg().setValue( "\"" + config.getOutputFile() + "\"" );
for ( int i = 0; i < config.getStartOptions().length; ++i )
{
cl.createArg().setValue( config.getStartOptions()[i] );
}
for ( int i = 0; i < objectFiles.size(); ++i )
{
File objFile = (File) objectFiles.get( i );
cl.createArg().setValue( "+\"" + objFile.getPath() + "\"" );
}
return cl;
}