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


Java Commandline.setExecutable方法代码示例

本文整理汇总了Java中org.codehaus.plexus.util.cli.Commandline.setExecutable方法的典型用法代码示例。如果您正苦于以下问题:Java Commandline.setExecutable方法的具体用法?Java Commandline.setExecutable怎么用?Java Commandline.setExecutable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.plexus.util.cli.Commandline的用法示例。


在下文中一共展示了Commandline.setExecutable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: getValue

import org.codehaus.plexus.util.cli.Commandline; //导入方法依赖的package包/类
public static String getValue( String valueType, String folderName, String folderKey )
    throws NativeBuildException
{
    Commandline cl = new Commandline();
    cl.setExecutable( "reg" );
    cl.createArg().setValue( "query" );
    cl.createArg().setValue( folderName );
    cl.createArg().setValue( "/v" );
    cl.createArg().setValue( folderKey );

    CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();

    try
    {
        int ok = CommandLineUtils.executeCommandLine( cl, stdout, stderr );

        if ( ok != 0 )
        {
            return null;
        }
    }
    catch ( CommandLineException e )
    {
        throw new NativeBuildException( e.getMessage(), e );
    }

    String result = stdout.getOutput();

    int p = result.indexOf( valueType );

    if ( p == -1 )
    {
        return null;
    }

    return result.substring( p + valueType.length() ).trim();
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:39,代码来源:RegQuery.java

示例5: run

import org.codehaus.plexus.util.cli.Commandline; //导入方法依赖的package包/类
public void run( ManifestConfiguration config )
    throws NativeBuildException
{
    Commandline cl = new Commandline();

    cl.setExecutable( "mt.exe" );
    cl.setWorkingDirectory( config.getWorkingDirectory().getPath() );

    cl.createArg().setValue( "-manifest" );

    int manifestType = 0;

    if ( "EXE".equalsIgnoreCase( FileUtils.getExtension( config.getInputFile().getPath() ) ) )
    {
        manifestType = 1;
    }
    else if ( "DLL".equalsIgnoreCase( FileUtils.getExtension( config.getInputFile().getPath() ) ) )
    {
        manifestType = 2;
    }

    if ( manifestType == 0 )
    {
        throw new NativeBuildException( "Unknown manifest input file type: " + config.getInputFile() );
    }

    cl.createArg().setFile( config.getManifestFile() );
    cl.createArg().setValue( "-outputresource:" + config.getInputFile() + ";" + manifestType );

    EnvUtil.setupCommandlineEnv( cl, config.getEnvFactory() );

    CommandLineUtil.execute( cl, this.getLogger() );
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:34,代码来源:MSVCManifest.java

示例6: run

import org.codehaus.plexus.util.cli.Commandline; //导入方法依赖的package包/类
public void run( File file )
    throws NativeBuildException
{
    Commandline cl = new Commandline();

    cl.setExecutable( "ranlib" );

    cl.createArg().setValue( file.getAbsolutePath() );

    CommandLineUtil.execute( cl, this.getLogger() );
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:12,代码来源:DefaultRanlib.java

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

示例8: getScmUrl

import org.codehaus.plexus.util.cli.Commandline; //导入方法依赖的package包/类
public static String getScmUrl( File repositoryRootFile )
    throws CommandLineException
{
    String repositoryRoot = repositoryRootFile.getAbsolutePath();

    // TODO: it'd be great to build this into CommandLineUtils somehow
    // TODO: some way without a custom cygwin sys property?
    if ( "true".equals( System.getProperty( "cygwin" ) ) )
    {
        Commandline cl = new Commandline();

        cl.setExecutable( "cygpath" );

        cl.createArg().setValue( "--unix" );

        cl.createArg().setValue( repositoryRoot );

        CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
        
        int exitValue = CommandLineUtils.executeCommandLine( cl, stdout, null );

        if ( exitValue != 0 )
        {
            throw new CommandLineException( "Unable to convert cygwin path, exit code = " + exitValue );
        }

        repositoryRoot = stdout.getOutput().trim();
    }
    else if ( Os.isFamily( "windows" ) )
    {
        repositoryRoot = "/" + StringUtils.replace( repositoryRoot, "\\", "/" );
    }

    return "scm:javasvn:file://" + repositoryRoot;
}
 
开发者ID:olamy,项目名称:maven-scm-provider-svnjava,代码行数:36,代码来源:SvnJavaScmTestUtils.java

示例9: _createCommandLine

import org.codehaus.plexus.util.cli.Commandline; //导入方法依赖的package包/类
/**
 * Creates the command line for the new JVM based on the current
 * configuration.
 *
 * @return The command line used to fork the JVM, never <code>null</code>.
 */
private Commandline _createCommandLine ()
{
  /*
   * NOTE: This method is designed to work with plexus-utils:1.1 which is used
   * by all Maven versions before 2.0.6 regardless of our plugin dependency.
   * Therefore, we use setWorkingDirectory(String) rather than
   * setWorkingDirectory(File) and addArguments() rather than createArg().
   */

  final Commandline cli = new Commandline ();

  cli.setExecutable (this.executable);

  if (this.workingDirectory != null)
  {
    cli.setWorkingDirectory (this.workingDirectory.getAbsolutePath ());
  }

  final String classPath = _getClassPath ();
  if (classPath != null && classPath.length () > 0)
  {
    cli.addArguments (new String [] { "-cp", classPath });
  }

  if (this.mainClass != null && this.mainClass.length () > 0)
  {
    cli.addArguments (new String [] { this.mainClass });
  }

  cli.addArguments (_getArguments ());

  return cli;
}
 
开发者ID:phax,项目名称:ph-javacc-maven-plugin,代码行数:40,代码来源:ForkedJvm.java

示例10: copyDependenciesTest

import org.codehaus.plexus.util.cli.Commandline; //导入方法依赖的package包/类
public void copyDependenciesTest(File dependencyFolder) throws MojoFailureException,
        MojoExecutionException {
    getLog().info("Start to copy dependencies");
    Commandline cl = new Commandline();
    cl.setExecutable("mvn");
    cl.createArg().setValue("clean");
    cl.createArg().setValue("dependency:copy-dependencies");
    cl.createArg().setValue("-DoutputDirectory=" + dependencyFolder.getAbsolutePath());
    cl.createArg().setValue("-Dsilent=true");
    String excludedArtifactIds = this.getTestDependencyArtifactIds();
    if (!excludedArtifactIds.isEmpty()) {
        cl.createArg().setValue("-DexcludeArtifactIds=" + excludedArtifactIds);
        getLog().info("====Excluded artifact ids: " + excludedArtifactIds);
    } else {
        getLog().info("====No excluded artifact ids");
    }
    WriterStreamConsumer systemOut = new WriterStreamConsumer(
            new OutputStreamWriter(System.out));
    int result = -1;
    try {
        result = CommandLineUtils.executeCommandLine(cl, systemOut, systemOut);
    } catch (CommandLineException e) {
        String message = "Failed to execute command: " + cl.toString();
        throw new MojoFailureException(message);
    }
    if (result != 0) {
        getLog().error("Failed to copy dependencies");
        System.exit(result);
    }
}
 
开发者ID:vongosling,项目名称:dependency-mediator,代码行数:31,代码来源:MavenCommandLineMojo.java

示例11: execute

import org.codehaus.plexus.util.cli.Commandline; //导入方法依赖的package包/类
private boolean execute(String command, String... args) throws GitException {
	Commandline cl = new Commandline();
	cl.setExecutable("git");
	cl.createArg().setValue(command);
	cl.setWorkingDirectory(workingDirectory.getAbsolutePath());
	
	//args
	for (int i = 0; i < args.length; i++){
		cl.createArg().setValue(args[i]);
	}
	
	if (log.isInfoEnabled()) {
		log.info("[" + cl.getWorkingDirectory().getAbsolutePath() + "] Executing: " + cl);
	}
	
	int exitCode;
	try {
		exitCode = CommandLineUtils.executeCommandLine(cl, stdout, stderr);
	} catch (CommandLineException e) {
		throw new GitException("Error while executing command.", e);
	}

	if(log.isDebugEnabled()){
		log.debug("Run: " + cl + " / $? = " + exitCode);
	}
	
	return exitCode == 0;
}
 
开发者ID:opoo,项目名称:opoopress,代码行数:29,代码来源:Git.java

示例12: detectJavaClasspath

import org.codehaus.plexus.util.cli.Commandline; //导入方法依赖的package包/类
private boolean detectJavaClasspath( Artifact javaBootClasspathDetector, String javaExecutable )
    throws CommandLineException, MojoFailureException
{
    final Commandline cli = new Commandline();
    cli.setWorkingDirectory( project.getBasedir().getAbsolutePath() );
    cli.setExecutable( javaExecutable );
    cli.addEnvironment( "CLASSPATH", "" );
    cli.addEnvironment( "JAVA_HOME", "" );
    cli.addArguments( new String[]{ "-jar", javaBootClasspathDetector.getFile().getAbsolutePath() } );

    final CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
    final CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode = CommandLineUtils.executeCommandLine( cli, stdout, stderr );
    if ( exitCode != 0 )
    {
        getLog().debug( "Stdout: " + stdout.getOutput() );
        getLog().debug( "Stderr: " + stderr.getOutput() );
        getLog().debug( "Exit code = " + exitCode );
        if ( skipIfNoJavaHome )
        {
            getLog().warn( "Skipping signature generation as could not auto-detect java boot classpath for "
                               + javaExecutable );
            return false;
        }
        throw new MojoFailureException( "Could not auto-detect java boot classpath for " + javaExecutable );
    }
    String[] classpath = StringUtils.split( stdout.getOutput(), File.pathSeparator );
    javaHomeClassPath = new File[classpath.length];
    for ( int j = 0; j < classpath.length; j++ )
    {
        javaHomeClassPath[j] = new File( classpath[j] );
    }
    return true;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:35,代码来源:BuildSignaturesMojo.java

示例13: executeCommand

import org.codehaus.plexus.util.cli.Commandline; //导入方法依赖的package包/类
@Override
public void executeCommand(String executable, List<String> commands, File workingDirectory,
                           boolean failsOnErrorOutput) throws ExecutionException {
    if (commands == null) {
        commands = new ArrayList<String>();
    }
    stdOut = new StreamConsumerImpl(logger, captureStdOut);
    stdErr = new ErrorStreamConsumer(logger, errorListener, captureStdErr);
    commandline = new Commandline();
    if (customShell != null) {
        commandline.setShell(customShell);
    }
    commandline.setExecutable(executable);

    // Add the environment variables as needed
    if (environment != null) {
        for (Map.Entry<String, String> entry : environment.entrySet()) {
            commandline.addEnvironment(entry.getKey(), entry.getValue());
        }
    }

    commandline.addArguments(commands.toArray(new String[commands.size()]));
    if (workingDirectory != null && workingDirectory.exists()) {
        commandline.setWorkingDirectory(workingDirectory.getAbsolutePath());
    }
    try {
        logger.debug("ANDROID-040-000: Executing command: Commandline = " + commandline);
        result = CommandLineUtils.executeCommandLine(commandline, stdOut, stdErr);
        if (logger != null) {
            logger.debug("ANDROID-040-000: Executed command: Commandline = " + commandline + ", Result = "
                    + result);
        } else {
            System.out.println("ANDROID-040-000: Executed command: Commandline = " + commandline
                    + ", Result = " + result);
        }
        if (failsOnErrorOutput && stdErr.hasError() || result != 0) {
            throw new ExecutionException("ANDROID-040-001: Could not execute: Command = "
                    + commandline.toString() + ", Result = " + result);
        }
    } catch (CommandLineException e) {
        throw new ExecutionException("ANDROID-040-002: Could not execute: Command = "
                + commandline.toString() + ", Error message = " + e.getMessage());
    }
    setPid(commandline.getPid());
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:46,代码来源:CommandExecutor.java

示例14: createJavahCommand

import org.codehaus.plexus.util.cli.Commandline; //导入方法依赖的package包/类
protected Commandline createJavahCommand( JavahConfiguration config )
    throws NativeBuildException
{
    this.validateConfiguration( config );

    Commandline cl = new Commandline();

    if ( config.getWorkingDirectory() != null )
    {
        cl.setWorkingDirectory( config.getWorkingDirectory().getPath() );
    }

    cl.setExecutable( this.getJavaHExecutable( config ) );

    if ( config.getFileName() != null && config.getFileName().length() > 0 )
    {
        File outputFile = new File( config.getOutputDirectory(), config.getFileName() );
        cl.createArg().setValue( "-o" );
        cl.createArg().setFile( outputFile );
    }
    else
    {
        if ( config.getOutputDirectory() != null )
        {
            cl.createArg().setValue( "-d" );
            cl.createArg().setFile( config.getOutputDirectory() );
        }
    }

    String[] classPaths = config.getClassPaths();

    StringBuffer classPathBuffer = new StringBuffer();

    for ( int i = 0; i < classPaths.length; ++i )
    {
        classPathBuffer.append( classPaths[i] );
        if ( i != classPaths.length - 1 )
        {
            classPathBuffer.append( File.pathSeparatorChar );
        }
    }

    if ( config.getUseEnvClasspath() )
    {
        cl.addEnvironment( "CLASSPATH", classPathBuffer.toString() );
    }
    else
    {
        cl.createArg().setValue( "-classpath" );

        cl.createArg().setValue( classPathBuffer.toString() );
    }

    if ( config.getVerbose() )
    {
        cl.createArg().setValue( "-verbose" );
    }

    cl.addArguments( config.getClassNames() );

    return cl;
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:63,代码来源:JavahExecutable.java

示例15: getCommandLine

import org.codehaus.plexus.util.cli.Commandline; //导入方法依赖的package包/类
protected Commandline getCommandLine( MessageCompilerConfiguration config, File source )
    throws NativeBuildException
{

    Commandline cl = new Commandline();

    EnvUtil.setupCommandlineEnv( cl, config.getEnvFactory() );

    if ( config.getWorkingDirectory() != null )
    {
        cl.setWorkingDirectory( config.getWorkingDirectory().getPath() );
    }

    if ( config.getExecutable() == null || config.getExecutable().trim().length() == 0 )
    {
        config.setExecutable( "mc.exe" );
    }
    cl.setExecutable( config.getExecutable().trim() );

    cl.addArguments( config.getOptions() );

    if ( config.getOutputDirectory() != null && config.getOutputDirectory().getPath().trim().length() != 0 )
    {
        cl.createArg().setValue( "-r" );
        cl.createArg().setValue( config.getOutputDirectory().getPath() );

        cl.createArg().setValue( "-h" );
        cl.createArg().setValue( config.getOutputDirectory().getPath() );

    }

    if ( config.getDebugOutputDirectory() != null
        && config.getDebugOutputDirectory().getPath().trim().length() != 0 )
    {
        cl.createArg().setValue( "-x" );
        cl.createArg().setValue( config.getDebugOutputDirectory().getPath() );
    }

    cl.createArg().setValue( source.getPath() );

    return cl;
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:43,代码来源:MSVCMessageCompiler.java


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