java - 闭包编译器 : create_name_map_files from Java API

标签 java closures google-closure-compiler google-closure google-closure-library

从命令行我可以获得从 compiler.jar 重命名的函数的别名列表

帮助说:

java -jar compiler.jar --help
[...]
--create_name_map_files                : If true, variable renaming and
                                         property renaming map files will be
                                         produced as {binary name}_vars_map.out
                                         and {binary name}_props_map.out. Note
                                         that this flag cannot be used in
                                         conjunction with either variableMapOut
                                         putFile or property_map_output_file
--create_source_map VAL                : If specified, a source map file
                                         mapping the generated source files
                                         back to the original source file will
                                         be output to the specified path. The
                                         %outname% placeholder will expand to
                                         the name of the output file that the
                                         source map corresponds to.
[...]

那么,如何从内联 java 中获取“create_name_map_files”?我查看了 AbstractCommandLineRunner.java,但与此命令行选项相关的所有类/方法都是私有(private)的,无法从我的代码中访问。

我的代码:

CompilerOptions opt = new CompilerOptions();

// decide mode
compilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(opt);
opt.prettyPrint = false;

Compiler.setLoggingLevel(Level.OFF);

Compiler compressor = new Compiler();
compressor.disableThreads();

List<SourceFile> inputs = ...;
List<SourceFile> externs = ...;

compressor.compile(externs, inputs, opt); 

最佳答案

您可以只使用选项:variable_map_output_file filename, Prop 也是如此。

请注意:标志 variable_map_output_file 和 create_name_map_files 不能同时使用。

关于java - 闭包编译器 : create_name_map_files from Java API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19875654/

相关文章:

java - OAuth2 Spring boot 缺少必需的“用户名

java - Spring框架和Spring Boot的区别?

java - 如何声明不同类型的HashMap?

Python 闭包困惑

javascript - 闭包编译器在 Mustache 标签上抛出错误

java - MediaPlayer "android "始终为空?

javascript - 访问有关导致 indexedDB 中请求出错的数据对象的信息

javascript - 使用 Javascript Promise,如何关闭 `then` 中父作用域的局部变量?

javascript - 是否可以为闭包编译器添加 @language ECMASCRIPT5 注释 JavaScript?

javascript - 关闭: change ENABLE_DEBUG_LOADER before base. js加载了吗?