当前位置: 首页>>代码示例>>Java>>正文


Java Commandline类代码示例

本文整理汇总了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());
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:17,代码来源:GccCompilerTest.java

示例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() );
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:18,代码来源:CCompilerTest.java

示例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 ) );
        }
    }
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:17,代码来源:EnvUtil.java

示例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 );
    }
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:26,代码来源:CommandLineUtil.java

示例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());
}
 
开发者ID:CodeFX-org,项目名称:JDeps-Maven-Plugin,代码行数:19,代码来源:JdkInternalsExecutor.java

示例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;
}
 
开发者ID:mojohaus,项目名称:buildnumber-maven-plugin,代码行数:20,代码来源:BuildNumberMojoTest.java

示例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();
}
 
开发者ID:ferstl,项目名称:depgraph-maven-plugin,代码行数:22,代码来源:DocumentationIntegrationTest.java

示例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);
  }
}
 
开发者ID:klieber,项目名称:phantomjs-maven-plugin,代码行数:22,代码来源:PhantomJsProcessBuilder.java

示例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;
}
 
开发者ID:klieber,项目名称:phantomjs-maven-plugin,代码行数:21,代码来源:PhantomJsProcessBuilder.java

示例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);
        }
    }
}
 
开发者ID:datanucleus,项目名称:datanucleus-maven-plugin,代码行数:24,代码来源:AbstractEnhancerEnhanceMojo.java

示例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;
}
 
开发者ID:CodeFX-org,项目名称:jdeps-wall-of-shame,代码行数:8,代码来源:JdkInternalsExecutor.java

示例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());
}
 
开发者ID:CodeFX-org,项目名称:jdeps-wall-of-shame,代码行数:8,代码来源:JdkInternalsExecutor.java

示例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());
}
 
开发者ID:CodeFX-org,项目名称:jdeps-wall-of-shame,代码行数:11,代码来源:JdkInternalsExecutor.java

示例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;
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:13,代码来源:BCCCompiler.java

示例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;

}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:34,代码来源:TLibLinker.java


注:本文中的org.codehaus.plexus.util.cli.Commandline类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。