本文整理汇总了Java中org.apache.tools.ant.types.Commandline.getArguments方法的典型用法代码示例。如果您正苦于以下问题:Java Commandline.getArguments方法的具体用法?Java Commandline.getArguments怎么用?Java Commandline.getArguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tools.ant.types.Commandline
的用法示例。
在下文中一共展示了Commandline.getArguments方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: verifyArguments
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
private void verifyArguments(Commandline cmd) {
if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
for (String arg : cmd.getArguments()) {
if ("-Xnew".equals(arg)) {
throw new BuildException("JDK9 has removed support for -Xnew");
}
}
}
}
示例3: writeExternalArgs
import org.apache.tools.ant.types.Commandline; //导入方法依赖的package包/类
private void writeExternalArgs(final Commandline toExecute) {
// If using an external file, write the command line options to it
File optionsTmpFile = null;
try {
optionsTmpFile = FILE_UTILS.createTempFile(
"javadocOptions", "", null, true, true);
final String[] listOpt = toExecute.getArguments();
toExecute.clearArgs();
toExecute.createArgument().setValue(
"@" + optionsTmpFile.getAbsolutePath());
try (BufferedWriter optionsListWriter = new BufferedWriter(
new FileWriter(optionsTmpFile.getAbsolutePath(), true))) {
for (final String opt : listOpt) {
if (opt.startsWith("-J-")) {
toExecute.createArgument().setValue(opt);
} else if (opt.startsWith("-")) {
optionsListWriter.write(opt);
optionsListWriter.write(" ");
} else {
optionsListWriter.write(quoteString(opt));
optionsListWriter.newLine();
}
}
}
} catch (final IOException ex) {
if (optionsTmpFile != null) {
optionsTmpFile.delete();
}
throw new BuildException(
"Error creating or writing temporary file for javadoc options",
ex, getLocation());
}
}