本文整理汇总了Java中com.sun.tools.javac.main.CommandLine类的典型用法代码示例。如果您正苦于以下问题:Java CommandLine类的具体用法?Java CommandLine怎么用?Java CommandLine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommandLine类属于com.sun.tools.javac.main包,在下文中一共展示了CommandLine类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.sun.tools.javac.main.CommandLine; //导入依赖的package包/类
public Result run(String[] argv) {
try {
argv = CommandLine.parse(argv);
} catch (IOException e) {
throw new IOError(e);
}
List<String> javacOpts = new ArrayList<>();
List<String> sources = new ArrayList<>();
for (String arg : argv) {
// TODO(cushon): is there a better way to categorize javacopts?
if (!arg.startsWith("-") && arg.endsWith(".java")) {
sources.add(arg);
} else {
javacOpts.add(arg);
}
}
StandardJavaFileManager fileManager = new MaskedFileManager();
return run(
javacOpts.toArray(new String[0]),
fileManager,
ImmutableList.copyOf(fileManager.getJavaFileObjectsFromStrings(sources)),
/* processors= */ null);
}
示例2: traverse
import com.sun.tools.javac.main.CommandLine; //导入依赖的package包/类
/**
* Traverses an array of arguments and performs the appropriate callbacks.
*
* @param args the arguments to traverse.
*/
void traverse(String[] args) {
try {
args = CommandLine.parse(args); // Detect @file and load it as a command line.
} catch (java.io.IOException e) {
throw new IllegalArgumentException("Problem reading @"+e.getMessage());
}
ArgumentIterator argIter = new ArgumentIterator(Arrays.asList(args));
nextArg:
while (argIter.hasNext()) {
String arg = argIter.next();
if (arg.startsWith("-")) {
for (Option opt : Option.values()) {
if (opt.processCurrent(argIter, this))
continue nextArg;
}
javacArg(arg);
// Does this javac argument take an argument? If so, don't
// let it pass on to sjavac as a source root directory.
for (com.sun.tools.javac.main.Option javacOpt : com.sun.tools.javac.main.Option.values()) {
if (javacOpt.matches(arg)) {
boolean takesArgument = javacOpt.hasArg();
boolean separateToken = !arg.contains(":") && !arg.contains("=");
if (takesArgument && separateToken)
javacArg(argIter.next());
}
}
} else {
sourceRoots(Arrays.asList(Paths.get(arg)));
}
}
}
示例3: begin
import com.sun.tools.javac.main.CommandLine; //导入依赖的package包/类
/**
* Main program - external wrapper. In order to maintain backward
* CLI compatibility, the execution is dispatched to the appropriate
* Start mechanism, depending on the doclet variant.
*
* The doclet tests are performed in the begin method, further on,
* this is to minimize argument processing and most importantly the impact
* of class loader creation, needed to detect the doclet class variants.
*/
@SuppressWarnings("deprecation")
Result begin(String... argv) {
// Preprocess @file arguments
try {
argv = CommandLine.parse(argv);
return begin(Arrays.asList(argv), Collections.emptySet());
} catch (IOException e) {
error("main.cant.read", e.getMessage());
return ERROR;
}
}
示例4: main
import com.sun.tools.javac.main.CommandLine; //导入依赖的package包/类
public static void main(String... args) throws IOException {
try {
String[] argv = CommandLine.parse("JDK_JAVAC_OPTIONS", EMPTY_ARRAY);
System.out.print(arrayToString(argv));
} catch (CommandLine.UnmatchedQuote ex) {
System.out.print("Exception: " + ex.variableName);
}
}