Каковы стандартные внешние параметры, предоставляемые командной строкой Google Closure, и как я могу получить их через интерфейс Java? - PullRequest
1 голос
/ 10 июля 2011

В настоящее время я использую этот код:

com.google.javascript.jscomp.Compiler.setLoggingLevel(Level.OFF);
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);

Однако я получаю много ошибок, подобных этой:

Error message: JSC_UNDEFINED_VARIABLE. variable Array is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable TypeError is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable Object is undefined 
Error message: JSC_UNDEFINED_VARIABLE. variable arguments is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable Number is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable Math is undefined

Очевидно, что это не правильно: такие вещи, как Object и arguments и т. д. - основная часть языка.Что я могу сделать, чтобы это исправить?

1 Ответ

1 голос
/ 11 июля 2011

Видели ли вы блог Майкла Болина об использовании Java API?

http://blog.bolinfest.com/2009/11/calling-closure-compiler-from-java.html

...