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


Java Commandline.setWorkingDirectory方法代码示例

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


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

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

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

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

示例4: _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

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

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

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

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

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

示例10: createLinkerCommandLine

import org.codehaus.plexus.util.cli.Commandline; //导入方法依赖的package包/类
protected Commandline createLinkerCommandLine( List objectFiles, LinkerConfiguration config )
{
    Commandline cl = new Commandline();

    cl.setWorkingDirectory( config.getWorkingDirectory().getPath() );

    String executable = EXECUTABLE;

    if ( !StringUtils.isBlank( config.getExecutable() ) )
    {
        executable = config.getExecutable();
    }

    cl.setExecutable( executable );

    for ( int i = 0; i < config.getStartOptions().length; ++i )
    {
        cl.createArg().setValue( config.getStartOptions()[i] );
    }

    // the next 2 are for completeness, the start options should be good enough
    for ( int i = 0; i < config.getMiddleOptions().length; ++i )
    {
        cl.createArg().setValue( config.getMiddleOptions()[i] );
    }

    for ( int i = 0; i < config.getEndOptions().length; ++i )
    {
        cl.createArg().setValue( config.getEndOptions()[i] );
    }

    cl.createArg().setFile( config.getOutputFile() );

    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,代码行数:44,代码来源:ArchiveLinker.java

示例11: 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:simpligility,项目名称:android-ndk-maven-plugin,代码行数:59,代码来源:CommandExecutor.java

示例12: executeReport

import org.codehaus.plexus.util.cli.Commandline; //导入方法依赖的package包/类
/**
 * @param unusedLocale the wanted locale (actually unused).
 * @throws MavenReportException if any
 */
protected void executeReport( Locale unusedLocale )
    throws MavenReportException
{

    File config = buildConfigurationFile();

    Commandline cli = new Commandline();
    cli.setWorkingDirectory( getBasedir().getAbsolutePath() );
    cli.setExecutable( getExecutablePath() );
    cli.createArgument().setValue( config.getAbsolutePath() );

    Writer stringWriter = new StringWriter();
    StreamConsumer out = new WriterStreamConsumer( stringWriter );
    StreamConsumer err = new WriterStreamConsumer( stringWriter );

    try
    {
        int returnCode = CommandLineUtils.executeCommandLine( cli, out, err );

        if ( !isQuiet() )
        {
            // Get all output from doxygen and put it to the log out of Maven.
            String[] lines = stringWriter.toString().split( "\n" );
            for ( int i = 0; i < lines.length; i++ )
            {
                lines[i] = lines[i].replaceAll( "\n|\r", "" );
                getLog().info( "doxygen: " + lines[i] );
            }
        }

        if ( returnCode != 0 )
        {
            throw new MavenReportException( "Failed to generate Doxygen documentation." );
        }

    }
    catch ( CommandLineException ex )
    {
        throw new MavenReportException( "Error while executing Doxygen.", ex );
    }

}
 
开发者ID:khmarbaise,项目名称:doxygen-maven-plugin,代码行数:47,代码来源:AbstractDoxygenMojo.java

示例13: getCommandLine

import org.codehaus.plexus.util.cli.Commandline; //导入方法依赖的package包/类
/**
 * Setup Compiler Command line
 */
protected Commandline getCommandLine(File srcFile, File destFile, CompilerConfiguration config)
        throws NativeBuildException {

    if (config.getExecutable() == null) {
        config.setExecutable("gcc");
    }

    Commandline cl = new Commandline();

    cl.setExecutable(config.getExecutable());

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

    this.setStartOptions(cl, config);

    this.setIncludePaths(cl, config.getIncludePaths());

    this.setIncludePaths(cl, config.getSystemIncludePaths());

    this.setMiddleOptions(cl, config);

    this.setOutputArgs(cl, destFile);

    this.setSourceArgs(cl, srcFile);

    this.setEndOptions(cl, config);

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

示例14: getCommandLine

import org.codehaus.plexus.util.cli.Commandline; //导入方法依赖的package包/类
/**
 * Setup Compiler Command line
 */
protected Commandline getCommandLine( File srcFile, File destFile, CompilerConfiguration config )
    throws NativeBuildException
{

    if ( config.getExecutable() == null )
    {
        config.setExecutable( "gcc" );
    }

    Commandline cl = new Commandline();

    cl.setExecutable( config.getExecutable() );

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

    this.setStartOptions( cl, config );

    this.setIncludePaths( cl, config.getIncludePaths() );

    this.setIncludePaths( cl, config.getSystemIncludePaths() );

    this.setMiddleOptions( cl, config );

    this.setOutputArgs( cl, destFile );

    this.setSourceArgs( cl, srcFile );

    this.setEndOptions( cl, config );

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


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