本文整理汇总了Java中org.apache.tools.ant.types.Commandline.Argument方法的典型用法代码示例。如果您正苦于以下问题:Java Commandline.Argument方法的具体用法?Java Commandline.Argument怎么用?Java Commandline.Argument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tools.ant.types.Commandline
的用法示例。
在下文中一共展示了Commandline.Argument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
public static void main(String[] args) {
final GroovyShell shell = new GroovyShell(new Binding());
final Groovy groovy = new Groovy();
for (int i = 1; i < args.length; i++) {
final Commandline.Argument argument = groovy.createArg();
argument.setValue(args[i]);
}
final AntBuilder builder = new AntBuilder();
groovy.setProject(builder.getProject());
groovy.parseAndRunScript(shell, null, null, null, new File(args[0]), builder);
}
示例2: createNewArgs
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
private void createNewArgs(String txt) throws IOException {
final String[] args = cmdline.getCommandline();
// Temporary file - delete on exit, create (assured unique name).
final File tempFile = FileUtils.getFileUtils().createTempFile(PREFIX, SUFFIX, null, true, true);
final String[] commandline = new String[args.length + 1];
ResourceGroovyMethods.write(tempFile, txt);
commandline[0] = tempFile.getCanonicalPath();
System.arraycopy(args, 0, commandline, 1, args.length);
super.clearArgs();
for (String arg : commandline) {
final Commandline.Argument argument = super.createArg();
argument.setValue(arg);
}
}
示例3: runS
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
/**
* Execute the given command, and return it's output
* @param cmdline command line to execute
* @return output of the command line
*/
protected String runS(Commandline cmdline) {
String outV = "opts.cc.runS.output" + pcnt++;
ExecTask exe = new ExecTask(this);
Commandline.Argument arg = exe.createArg();
exe.setExecutable(cmdline.getExecutable());
arg.setLine(Commandline.toString(cmdline.getArguments()));
exe.setOutputproperty(outV);
exe.execute();
return getProject().getProperty(outV);
}
示例4: setupKawaCommandline
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
/**
* Build the command line, translating the parameters into flags for
* java and kawa.repl.
* @param cmd the Commandline to be executed
*/
private void setupKawaCommandline(Commandline cmd) {
cmd.setExecutable(getSystemJava());
Path classpath = getCompileClasspath();
cmd.createArgument().setValue("-classpath");
cmd.createArgument().setPath(classpath);
cmd.createArgument().setValue("kawa.repl");
if (target != null) {
cmd.createArgument().setValue("--target");
cmd.createArgument().setValue(target);
}
if (destDir != null) {
cmd.createArgument().setValue("-d");
cmd.createArgument().setFile(destDir);
}
if (prefix != null) {
cmd.createArgument().setValue("-P");
cmd.createArgument().setValue(prefix);
}
if (language != null) {
cmd.createArgument().setValue("--"+language);
}
if (main) {
cmd.createArgument().setValue("--main");
}
if (applet) {
cmd.createArgument().setValue("--applet");
}
if (servlet) {
cmd.createArgument().setValue("--servlet");
}
if (fullTailCalls) {
cmd.createArgument().setValue("--full-tailcalls");
// } else {
// cmd.createArgument().setValue("--no-full-tailcalls");
}
if (moduleStatic != null) {
if ("yes".equals(moduleStatic) || "on".equals(moduleStatic) ||
"true".equals(moduleStatic))
cmd.createArgument().setValue("--module-static");
else if ("run".equals(moduleStatic))
cmd.createArgument().setValue("--module-static-run");
else if("no".equals(moduleStatic) || "off".equals(moduleStatic)
|| "false".equals(moduleStatic))
cmd.createArgument().setValue("--no-module-static");
}
if (warnUndefinedVariable) {
cmd.createArgument().setValue("--warn-undefined-variable");
}
if (warnAsError) {
cmd.createArgument().setValue("--warn-as-error");
}
// Add nested command line args.
for (Commandline.Argument arg : otherArgs) {
for (String p : arg.getParts()) {
cmd.createArgument().setValue(p); // should probably do some validation?
}
}
cmd.createArgument().setValue("-C");
}
示例5: createArg
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
public Commandline.Argument createArg() {
return cmdline.createArgument();
}
示例6: execute
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
/**
* Do the task.
* @throws BuildException if there is an error.
*/
@Override
public void execute() throws BuildException {
// load command line with optional attributes
optionalAttrs.forEach((name, value) -> cmdl.createArgument()
.setValue("-" + name + ":" + value.toString()));
if (targetFile == null || !targetFile.isFile()) {
throw new BuildException("Invalid target: %s", targetFile);
}
if (outputFile != null) {
cmdl.createArgument() .setValue("-" + OUTPUT_FILE + ":"
+ outputFile.replace('\\', '/'));
}
// use the directory containing the target as the output directory
File javaFile = new File(createOutputFileName(targetFile, outputFile,
plainText));
if (javaFile.exists()
&& targetFile.lastModified() < javaFile.lastModified()) {
log("Target is already built - skipping (" + targetFile + ")",
Project.MSG_VERBOSE);
return;
}
cmdl.createArgument().setValue(targetFile.getAbsolutePath());
final Path classpath = cmdl.createClasspath(getProject());
final File javaccJar = JavaCC.getArchiveFile(javaccHome);
classpath.createPathElement().setPath(javaccJar.getAbsolutePath());
classpath.addJavaRuntime();
cmdl.setClassname(JavaCC.getMainClass(classpath,
JavaCC.TASKDEF_TYPE_JJDOC));
cmdl.setMaxmemory(maxMemory);
final Commandline.Argument arg = cmdl.createVmArgument();
arg.setValue("-Dinstall.root=" + javaccHome.getAbsolutePath());
final Execute process =
new Execute(new LogStreamHandler(this,
Project.MSG_INFO,
Project.MSG_INFO),
null);
log(cmdl.describeCommand(), Project.MSG_VERBOSE);
process.setCommandline(cmdl.getCommandline());
try {
if (process.execute() != 0) {
throw new BuildException("JJDoc failed.");
}
} catch (IOException e) {
throw new BuildException("Failed to launch JJDoc", e);
}
}
示例7: execute
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
/**
* Run the task.
* @throws BuildException on error.
*/
@Override
public void execute() throws BuildException {
// load command line with optional attributes
optionalAttrs.forEach((name, value) -> cmdl.createArgument()
.setValue("-" + name + ":" + value));
// check the target is a file
if (targetFile == null || !targetFile.isFile()) {
throw new BuildException("Invalid target: %s", targetFile);
}
// use the directory containing the target as the output directory
if (outputDirectory == null) {
outputDirectory = new File(targetFile.getParent());
} else if (!outputDirectory.isDirectory()) {
throw new BuildException("Outputdir not a directory.");
}
cmdl.createArgument().setValue("-OUTPUT_DIRECTORY:"
+ outputDirectory.getAbsolutePath());
// determine if the generated java file is up-to-date
final File javaFile = getOutputJavaFile(outputDirectory, targetFile);
if (javaFile.exists()
&& targetFile.lastModified() < javaFile.lastModified()) {
log("Target is already built - skipping (" + targetFile + ")",
Project.MSG_VERBOSE);
return;
}
cmdl.createArgument().setValue(targetFile.getAbsolutePath());
final Path classpath = cmdl.createClasspath(getProject());
final File javaccJar = JavaCC.getArchiveFile(javaccHome);
classpath.createPathElement().setPath(javaccJar.getAbsolutePath());
classpath.addJavaRuntime();
cmdl.setClassname(JavaCC.getMainClass(classpath,
JavaCC.TASKDEF_TYPE_JAVACC));
cmdl.setMaxmemory(maxMemory);
final Commandline.Argument arg = cmdl.createVmArgument();
arg.setValue("-Dinstall.root=" + javaccHome.getAbsolutePath());
Execute.runCommand(this, cmdl.getCommandline());
}
示例8: addArg
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
/**
* Adds a nested {@code <arg>}.
* @param arg the argument to add to the kawa command line
*/
public void addArg(Commandline.Argument arg) {
otherArgs.add(arg);
}
示例9: createArg
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
/**
* Adds a command-line argument.
*
* @return new command line argument created
*/
public Commandline.Argument createArg() {
return cmdl.createArgument();
}
示例10: createArg
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
/**
* Adds a command-line argument.
*
* @return new command line argument created.
*/
public Commandline.Argument createArg() {
return cmdl.createArgument();
}
示例11: createJvmarg
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
/**
* Adds a JVM argument; ignored if not forking.
*
* @return create a new JVM argument so that any argument can be
* passed to the JVM.
* @see #setFork(boolean)
* @since Ant 1.2
*/
public Commandline.Argument createJvmarg() {
return getCommandline().createVmArgument();
}
示例12: createJvmarg
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
/**
* Adds a new JVM argument.
* @return create a new JVM argument so that any argument can be passed to the JVM.
* @see #setFork(boolean)
*/
public Commandline.Argument createJvmarg() {
return commandline.createVmArgument();
}
示例13: createJvmarg
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
/**
* Create a new JVM argument. Ignored if no JVM is forked.
* @param commandline the commandline to create the argument on
* @return create a new JVM argument so that any argument can
* be passed to the JVM.
* @see #setFork(boolean)
*/
public Commandline.Argument createJvmarg(CommandlineJava commandline) {
return commandline.createVmArgument();
}
示例14: createArg
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
/**
* Add a nested argument element to hand to the deployment tool; optional.
* @return A Commandline.Argument object representing the
* command line argument being passed when the deployment
* tool is run. IE: "-user=mark", "-password=venture"...
*/
public Commandline.Argument createArg() {
return java.createArg();
}
示例15: createJvmarg
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
/**
* Add a nested argument element to hand to the JVM running the
* deployment tool.
* Creates a nested arg element.
* @return A Commandline.Argument object representing the
* JVM command line argument being passed when the deployment
* tool is run. IE: "-ms64m", "-mx128m"...
*/
public Commandline.Argument createJvmarg() {
return java.createJvmarg();
}