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


Java Commandline类代码示例

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


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

示例1: logAndAddFilesToCompile

import org.apache.tools.ant.types.Commandline; //导入依赖的package包/类
/**
 * Add the file names to the Commandline. Log them in verbose mode.
 * @param cmd the Commandline to be executed
 */
private void logAndAddFilesToCompile(Commandline cmd) {
  log("Compilation " + cmd.describeArguments(),
      Project.MSG_VERBOSE);

  StringBuffer niceSourceList = new StringBuffer("File");
  if (compileList.length != 1) {
    niceSourceList.append("s");
  }
  niceSourceList.append(" to be compiled:");
  niceSourceList.append(StringUtils.LINE_SEP);

  for (int i = 0; i < compileList.length; i++) {
    String arg = compileList[i].getAbsolutePath();
    cmd.createArgument().setValue(arg);
    niceSourceList.append("    ");
    niceSourceList.append(arg);
    niceSourceList.append(StringUtils.LINE_SEP);
  }
  log(niceSourceList.toString(), Project.MSG_VERBOSE);
}
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:25,代码来源:Kawac.java

示例2: parseBuildArgs

import org.apache.tools.ant.types.Commandline; //导入依赖的package包/类
public static Map<String, String> parseBuildArgs(String commandLine) {
    // this also accounts for quote, escapes, ...
    Commandline parsed = new Commandline(commandLine);
    Map<String, String> result = new HashMap<>();

    String[] arguments = parsed.getArguments();
    for (int i = 0; i < arguments.length; i++) {
        String arg = arguments[i];
        if (arg.equals("--build-arg")) {
            if (arguments.length < i + 1) {
                throw new IllegalArgumentException("Missing parameter for --build-arg: " + commandLine);
            }
            String keyVal = arguments[i+1];

            String parts[] = keyVal.split("=", 2);
            if (parts.length != 2) {
                throw new IllegalArgumentException("Illegal syntax for --build-arg " + keyVal + ", need KEY=VALUE");
            }
            String key = parts[0];
            String value = parts[1];

            result.put(key, value);
        }
    }
    return result;
}
 
开发者ID:jenkinsci,项目名称:docker-workflow-plugin,代码行数:27,代码来源:DockerUtils.java

示例3: executeCmd

import org.apache.tools.ant.types.Commandline; //导入依赖的package包/类
protected boolean executeCmd (Commandline cmd)
{
	try
	{
		System.out.println (cmd.toString ());
		Execute exe = new Execute ();
		exe.setCommandline (cmd.getCommandline ());
		exe.execute ();
		if (exe.getExitValue () == 0)
			return false;
	}
	catch (Exception ex)
	{
	}
	return true;
}
 
开发者ID:coconut2015,项目名称:cookcc,代码行数:17,代码来源:Task.java

示例4: addToCommandline

import org.apache.tools.ant.types.Commandline; //导入依赖的package包/类
public void addToCommandline(Commandline cmdl)
{
    if (hasSelectors() || hasPatterns())
    {
        DirectoryScanner scanner = getDirectoryScanner(getProject());

        if (includeDirs)
        {
            addFiles(scanner.getBasedir(), scanner.getIncludedDirectories(), cmdl);
        }

        addFiles(scanner.getBasedir(), scanner.getIncludedFiles(), cmdl);
    }
    else if (spec != null)
    {
        cmdl.createArgument().setValue("-" + spec.getFullName() + "=");
    }
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:19,代码来源:FlexFileSet.java

示例5: addFiles

import org.apache.tools.ant.types.Commandline; //导入依赖的package包/类
protected void addFiles(File base, String[] files, Commandline cmdl)
{
    FileUtils utils = FileUtils.getFileUtils();

    if (spec == null)
    {
        for (int i = 0; i < files.length; i++)
        {
            cmdl.createArgument().setValue(utils.resolveFile(base, files[i]).getAbsolutePath());
        }
    }
    else
    {
        for (int i = 0; i < files.length; i++)
        {
            cmdl.createArgument().setValue("-" + spec.getFullName() + equalString() +
                                           utils.resolveFile(base, files[i]).getAbsolutePath());
        }
    }
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:21,代码来源:FlexFileSet.java

示例6: addFiles

import org.apache.tools.ant.types.Commandline; //导入依赖的package包/类
protected void addFiles(File base, String[] files, Commandline cmdl)
{
    FileUtils utils = FileUtils.getFileUtils();
 
    for (int i = 0; i < files.length; ++i)
    {
        File f = utils.resolveFile(base, files[i]);
        String absolutePath = f.getAbsolutePath();

        if( f.isFile() && !absolutePath.endsWith(".swc") && !absolutePath.endsWith(".ane") )
        	continue;

        if (spec != null)
        {
            cmdl.createArgument().setValue("-" + spec.getFullName() + equalString() + absolutePath);
        }
        else
        {
            cmdl.createArgument().setValue(absolutePath);
        }
    }    
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:23,代码来源:FlexSwcFileSet.java

示例7: run

import org.apache.tools.ant.types.Commandline; //导入依赖的package包/类
/**
 * Execute the created command line.
 *
 * @param  cmd            The command line to run.
 * @return                int the exit code.
 * @throws BuildException if something goes wrong
 */
protected int run(Commandline cmd) {
    try {
        Execute exe = new Execute(new LogStreamHandler(this,
                Project.MSG_INFO,
                Project.MSG_WARN));

        exe.setAntRun(getProject());
        exe.setWorkingDirectory(getProject().getBaseDir());
        exe.setCommandline(cmd.getCommandline());
        exe.setVMLauncher(false);  // Use the OS VM launcher so we get environment variables
        return exe.execute();
    } catch (java.io.IOException e) {
        throw new BuildException(e, getLocation());
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:23,代码来源:SOS.java

示例8: run

import org.apache.tools.ant.types.Commandline; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected boolean run(Commandline cmd, ProjectComponent log)
    throws BuildException {
    ExecuteJava ej = new ExecuteJava();
    Class<?> c = getN2aClass();
    if (c == null) {
        throw new BuildException(
            "Couldn't load Kaffe's Native2Ascii class");
    }

    cmd.setExecutable(c.getName());
    ej.setJavaCommand(cmd);
    ej.execute(log.getProject());
    // otherwise ExecuteJava has thrown an exception
    return true;
}
 
开发者ID:apache,项目名称:ant,代码行数:18,代码来源:KaffeNative2Ascii.java

示例9: checkOptions

import org.apache.tools.ant.types.Commandline; //导入依赖的package包/类
/**
 * Check the command line options.
 */
private void checkOptions(Commandline cmd) {
    if (getComment() != null) {
        cmd.createArgument().setValue(FLAG_COMMENT);
        cmd.createArgument().setValue(getComment());
    }

    if (getTask() != null) {
        cmd.createArgument().setValue(FLAG_TASK);
        cmd.createArgument().setValue(getTask());
    }

    if (getFile() != null) {
        cmd.createArgument().setValue(file.getAbsolutePath());
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:19,代码来源:CCMCheck.java

示例10: execute

import org.apache.tools.ant.types.Commandline; //导入依赖的package包/类
/**
 * Run the compilation.
 * @return true if the compiler ran with a zero exit result (ok)
 * @exception BuildException if the compilation has problems.
 */
@Override
public boolean execute() throws BuildException {
    attributes.log("Using modern compiler", Project.MSG_VERBOSE);
    Commandline cmd = setupModernJavacCommand();

    // Use reflection to be able to build on all JDKs >= 1.1:
    try {
        Class<?> c = Class.forName("com.sun.tools.javac.Main");
        Object compiler = c.newInstance();
        Method compile = c.getMethod("compile", String[].class);
        int result = ((Integer) compile.invoke(compiler,
            (Object) cmd.getArguments())).intValue();
        return result == MODERN_COMPILER_SUCCESS;
    } catch (Exception ex) {
        if (ex instanceof BuildException) {
            throw (BuildException) ex;
        }
        throw new BuildException("Error starting modern compiler",
                                 ex, location);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:27,代码来源:Javac13.java

示例11: execute

import org.apache.tools.ant.types.Commandline; //导入依赖的package包/类
/**
 * Executes the task.
 * <p>
 * Builds a command line to execute ccm and then calls Exec's run method
 * to execute the command line.
 * </p>
 * @throws BuildException on error
 */
@Override
public void execute() throws BuildException {
    Commandline commandLine = new Commandline();

    // build the command line from what we got the format
    // as specified in the CCM.EXE help
    commandLine.setExecutable(getCcmCommand());
    commandLine.createArgument().setValue(getCcmAction());

    checkOptions(commandLine);

    int result = run(commandLine);
    if (Execute.isFailure(result)) {
        throw new BuildException("Failed executing: " + commandLine,
            getLocation());
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:26,代码来源:CCMReconfigure.java

示例12: execOnVMS

import org.apache.tools.ant.types.Commandline; //导入依赖的package包/类
/**
 * helper method to execute our command on VMS.
 * @param cmd Commandline
 * @param firstFileName int
 * @return boolean
 */
private boolean execOnVMS(Commandline cmd, int firstFileName) {
    File vmsFile = null;
    try {
        vmsFile = JavaEnvUtils.createVmsJavaOptionFile(cmd.getArguments());
        String[] commandLine = {cmd.getExecutable(),
                                "-V",
                                vmsFile.getPath()};
        return 0 == executeExternalCompile(commandLine,
                        firstFileName,
                        true);

    } catch (IOException e) {
        throw new BuildException(
            "Failed to create a temporary file for \"-V\" switch");
    } finally {
        FileUtils.delete(vmsFile);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:25,代码来源:JavacExternal.java

示例13: releaseIsUsedForJava9

import org.apache.tools.ant.types.Commandline; //导入依赖的package包/类
@Test
public void releaseIsUsedForJava9() {
    LogCapturingJavac javac = new LogCapturingJavac();
    Project p = new Project();
    javac.setProject(p);
    javac.setCompiler("javac9");
    javac.setSource("6");
    javac.setTarget("6");
    javac.setRelease("6");
    javac.setSourcepath(new Path(p));
    SourceTargetHelperNoOverride sth = new SourceTargetHelperNoOverride();
    sth.setJavac(javac);
    Commandline cmd = new Commandline();
    sth.setupModernJavacCommandlineSwitches(cmd);
    assertContains("Ignoring source, target and bootclasspath as "
                   + "release has been set", javac.getLog());
    String[] args = cmd.getCommandline();
    assertEquals(5, args.length);
    assertEquals("-classpath", args[0]);
    assertEquals("-g:none", args[2]);
    assertEquals("--release", args[3]);
    assertEquals("6", args[4]);
}
 
开发者ID:apache,项目名称:ant,代码行数:24,代码来源:DefaultCompilerAdapterTest.java

示例14: exec

import org.apache.tools.ant.types.Commandline; //导入依赖的package包/类
/**
 * Launches the given command in a new process, in the given
 * working directory.
 *
 * @param project
 *        the Ant project.
 * @param cmd
 *        the command line to execute as an array of strings.
 * @param env
 *        the environment to set as an array of strings.
 * @param workingDir
 *        the working directory where the command should run.
 * @return the created Process.
 * @throws IOException
 *         probably forwarded from Runtime#exec.
 */
@Override
public Process exec(Project project, String[] cmd, String[] env,
                    File workingDir) throws IOException {
    try {
        if (project != null) {
            project.log("Execute:Java13CommandLauncher: "
                        + Commandline.describeCommand(cmd),
                        Project.MSG_DEBUG);
        }
        return Runtime.getRuntime().exec(cmd, env, workingDir);
    } catch (IOException ioex) {
        throw ioex;
    } catch (Exception exc) {
        // IllegalAccess, IllegalArgument, ClassCast
        throw new BuildException("Unable to execute command", exc);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:34,代码来源:Java13CommandLauncher.java

示例15: buildCmdLine

import org.apache.tools.ant.types.Commandline; //导入依赖的package包/类
/**
 * Build the command line
 * <p>
 * CheckOutFile required parameters: -server -name -password -database -project -file<br>
 * CheckOutFile optional parameters: -workdir -verbose -nocache -nocompression -soshome<br>
 *
 * CheckOutProject required parameters: -server -name -password -database -project<br>
 * CheckOutProject optional parameters:-workdir -recursive -verbose -nocache
 * -nocompression -soshome
 * </p>
 *
 * @return    Commandline the generated command to be executed
 */
@Override
protected Commandline buildCmdLine() {
    commandLine = new Commandline();

    // If we find a "file" attribute then act on a file otherwise act on a project
    if (getFilename() != null) {
        // add -command CheckOutFile to the commandline
        commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND);
        commandLine.createArgument().setValue(SOSCmd.COMMAND_CHECKOUT_FILE);
        // add -file xxxxx to the commandline
        commandLine.createArgument().setValue(SOSCmd.FLAG_FILE);
        commandLine.createArgument().setValue(getFilename());
    } else {
        // add -command CheckOutProject to the commandline
        commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND);
        commandLine.createArgument().setValue(SOSCmd.COMMAND_CHECKOUT_PROJECT);
        // look for a recursive option
        commandLine.createArgument().setValue(getRecursive());
    }

    getRequiredAttributes();
    getOptionalAttributes();

    return commandLine;
}
 
开发者ID:apache,项目名称:ant,代码行数:39,代码来源:SOSCheckout.java


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