通过Java将定义传递给Google闭包编译器

通过Java将定义传递给Google闭包编译器,java,javascript,google-closure-compiler,google-closure,Java,Javascript,Google Closure Compiler,Google Closure,正如标题所说,我希望通过Java API以编程方式将定义传递给Google闭包编译器 这是我当前的代码: com.google.javascript.jscomp.Compiler.setLoggingLevel(Level.INFO); com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler(); CompilerOptions options = new Compil

正如标题所说,我希望通过Java API以编程方式将定义传递给Google闭包编译器

这是我当前的代码:

com.google.javascript.jscomp.Compiler.setLoggingLevel(Level.INFO);
com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler();
CompilerOptions options = new CompilerOptions();
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
WarningLevel.VERBOSE.setOptionsForWarningLevel(options);

List<JSSourceFile> externs = new ArrayList<JSSourceFile>();
externs.add(JSSourceFile.fromFile(extern_src));

List<JSSourceFile> primary = new ArrayList<JSSourceFile>();
primary.add(JSSourceFile.fromFile(tmp));
compiler.compile(externs, primary, options);
for (JSError message : compiler.getWarnings()) {
    System.err.println("Warning message: " + message.toString());
}

for (JSError message : compiler.getErrors()) {
    System.err.println("Error message: " + message.toString());
}
com.google.javascript.jscomp.Compiler.setLoggingLevel(Level.INFO);
com.google.javascript.jscomp.Compiler Compiler=new com.google.javascript.jscomp.Compiler();
CompilerOptions=new CompilerOptions();
编译级别。高级优化。设置编译级别的选项(选项);
WarningLevel.VERBOSE.setOptionsForWarningLevel(选项);
List externs=new ArrayList();
add(JSSourceFile.fromFile(extern_src));
List primary=new ArrayList();
add(JSSourceFile.fromFile(tmp));
compile.compile(外部、主、选项);
for(JSError消息:compiler.getWarnings()){
System.err.println(“警告消息:+message.toString());
}
for(JSError消息:compiler.getErrors()){
System.err.println(“错误消息:+message.toString());
}
您要填充

该值必须是布尔值、数值或字符串文本的
节点。
要为布尔文字创建值,请使用以下值

new Node(Token.TRUE)
其中
节点
令牌
都来自包
com.google.javascript.jscomp.rhino

我相信
Token.STRING
Token.NUMBER
是其他类型值的标记类型,但不要引用我的话

new Node(Token.TRUE)