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


Java CommandLineUtils类代码示例

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


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

示例1: hasOption

import org.codehaus.plexus.util.cli.CommandLineUtils; //导入依赖的package包/类
private boolean hasOption(String longName, String shortName) {
    String defOpts = getDefaultOptions();
    if (defOpts != null) {
        try {
            String[] strs = CommandLineUtils.translateCommandline(defOpts);
            for (String s : strs) {
                s = s.trim();
                if (s.startsWith(shortName) || s.startsWith(longName)) {
                    return true;
                }
            }
        } catch (Exception ex) {
            Logger.getLogger(MavenSettings.class.getName()).log(Level.FINE, "Error parsing global options:{0}", defOpts);
            //will check for contains of -X be enough?
            return defOpts.contains(longName) || defOpts.contains(shortName);
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:MavenSettings.java

示例2: getCustomGlobalUserProperties

import org.codehaus.plexus.util.cli.CommandLineUtils; //导入依赖的package包/类
static Map<String, String> getCustomGlobalUserProperties() {
    //maybe set org.eclipse.aether.ConfigurationProperties.USER_AGENT with netbeans specific value.
    Map<String, String> toRet = new HashMap<String, String>();
    String options = getPreferences().get(PROP_DEFAULT_OPTIONS, "");
    try {
        
        String[] cmdlines = CommandLineUtils.translateCommandline(options);
        if (cmdlines != null) {
            for (String cmd : cmdlines) {
                if (cmd != null && cmd.startsWith("-D")) {
                    cmd = cmd.substring("-D".length());
                    int ind = cmd.indexOf('=');
                    if (ind > -1) {
                        String key = cmd.substring(0, ind);
                        String val = cmd.substring(ind + 1);
                        toRet.put(key, val);
                    }
                }
            }
        }
        return toRet;
    } catch (Exception ex) {
        LOG.log(Level.FINE, "cannot parse " + options, ex);
        return Collections.emptyMap();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:EmbedderFactory.java

示例3: parseCommandlineArgs

import org.codehaus.plexus.util.cli.CommandLineUtils; //导入依赖的package包/类
/**
 * Parses the argument string given by the user. Strings are recognized as everything between STRING_WRAPPER.
 * PARAMETER_DELIMITER is ignored inside a string. STRING_WRAPPER and PARAMETER_DELIMITER can be escaped using
 * ESCAPE_CHAR.
 *
 * @return Array of String representing the arguments
 * @throws MojoExecutionException for wrong formatted arguments
 */
protected String[] parseCommandlineArgs()
    throws MojoExecutionException
{
    if ( commandlineArgs == null )
    {
        return null;
    }
    else
    {
        try
        {
            return CommandLineUtils.translateCommandline( commandlineArgs );
        }
        catch ( Exception e )
        {
            throw new MojoExecutionException( e.getMessage() );
        }
    }
}
 
开发者ID:mojohaus,项目名称:exec-maven-plugin,代码行数:28,代码来源:AbstractExecMojo.java

示例4: execute

import org.codehaus.plexus.util.cli.CommandLineUtils; //导入依赖的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.CommandLineUtils; //导入依赖的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: createEnvironmentVars

import org.codehaus.plexus.util.cli.CommandLineUtils; //导入依赖的package包/类
/**
 * Creates the environment required when launching Cassandra or the CLI tools.
 *
 * @return the environment required when launching Cassandra or the CLI tools.
 */
protected Map<String, String> createEnvironmentVars()
{
    Map<String, String> enviro = new HashMap<String, String>();
    try
    {
        Properties systemEnvVars = CommandLineUtils.getSystemEnvVars();
        for ( Map.Entry entry : systemEnvVars.entrySet() )
        {
            enviro.put( (String) entry.getKey(), (String) entry.getValue() );
        }
    }
    catch ( IOException x )
    {
        getLog().error( "Could not assign default system enviroment variables.", x );
    }
    enviro.put( "CASSANDRA_CONF", new File( cassandraDir, "conf" ).getAbsolutePath() );
    return enviro;
}
 
开发者ID:mojohaus,项目名称:cassandra-maven-plugin,代码行数:24,代码来源:AbstractCassandraMojo.java

示例7: getJvmArgs

import org.codehaus.plexus.util.cli.CommandLineUtils; //导入依赖的package包/类
private List<String> getJvmArgs()
{
	List<String> extra = new ArrayList<String>();
	String userExtraJvmArgs = getExtraJvmArgs();
	if (userExtraJvmArgs != null)
	{
		try
		{
			return new ArrayList<String>(Arrays.asList(CommandLineUtils.translateCommandline(StringUtils
			    .removeDuplicateWhitespace(userExtraJvmArgs))));
		}
		catch (Exception e)
		{
			throw new RuntimeException(e);
		}
	}
	return extra;
}
 
开发者ID:CruxFramework,项目名称:crux-maven-plugin,代码行数:19,代码来源:AbstractShellMojo.java

示例8: isSvn18

import org.codehaus.plexus.util.cli.CommandLineUtils; //导入依赖的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

示例9: getDotExecutable

import org.codehaus.plexus.util.cli.CommandLineUtils; //导入依赖的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

示例10: extractDebugJVMOptions

import org.codehaus.plexus.util.cli.CommandLineUtils; //导入依赖的package包/类
static List<String> extractDebugJVMOptions(String argLine) throws Exception {
    String[] split = CommandLineUtils.translateCommandline(argLine);
    List<String> toRet = new ArrayList<String>();
    for (String arg : split) {
        if ("-Xdebug".equals(arg)) { //NOI18N
            continue;
        }
        if ("-Djava.compiler=none".equals(arg)) { //NOI18N
            continue;
        }
        if ("-Xnoagent".equals(arg)) { //NOI18N
            continue;
        }
        if (arg.startsWith("-Xrunjdwp")) { //NOI18N
            continue;
        }
        if (arg.equals("-agentlib:jdwp")) { //NOI18N
            continue;
        }
        if (arg.startsWith("-agentlib:jdwp=")) { //NOI18N
            continue;
        }
        if (arg.trim().length() == 0) {
            continue;
        }
        toRet.add(arg);
    }
    return toRet;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:CosChecker.java

示例11: parseArgs

import org.codehaus.plexus.util.cli.CommandLineUtils; //导入依赖的package包/类
private static String[] parseArgs(String arguments) {
	if (arguments == null || arguments.trim().isEmpty()) {
		return NO_ARGS;
	}
	try {
		arguments = arguments.replace('\n', ' ').replace('\t', ' ');
		return CommandLineUtils.translateCommandline(arguments);
	}
	catch (Exception ex) {
		throw new IllegalArgumentException(
				"Failed to parse arguments [" + arguments + "]", ex);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:RunArguments.java

示例12: handleSystemPropertyArguments

import org.codehaus.plexus.util.cli.CommandLineUtils; //导入依赖的package包/类
private void handleSystemPropertyArguments( String argsProp, List<String> commandArguments )
    throws MojoExecutionException
{
    getLog().debug( "got arguments from system properties: " + argsProp );

    try
    {
        String[] args = CommandLineUtils.translateCommandline( argsProp );
        commandArguments.addAll( Arrays.asList( args ) );
    }
    catch ( Exception e )
    {
        throw new MojoExecutionException( "Couldn't parse systemproperty 'exec.args'" );
    }
}
 
开发者ID:mojohaus,项目名称:exec-maven-plugin,代码行数:16,代码来源:ExecMojo.java

示例13: execute

import org.codehaus.plexus.util.cli.CommandLineUtils; //导入依赖的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

示例14: throwCommandLineException

import org.codehaus.plexus.util.cli.CommandLineUtils; //导入依赖的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

示例15: getValue

import org.codehaus.plexus.util.cli.CommandLineUtils; //导入依赖的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


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