Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ClosureCompiler:从JavaAPI创建\u名称\u映射\u文件_Java_Closures_Google Closure Compiler_Google Closure_Google Closure Library - Fatal编程技术网

ClosureCompiler:从JavaAPI创建\u名称\u映射\u文件

ClosureCompiler:从JavaAPI创建\u名称\u映射\u文件,java,closures,google-closure-compiler,google-closure,google-closure-library,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

从命令行中,我可以从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中获取“创建名称映射文件”?我查看了AbstractCommandLineRunner.java,但与此命令行选项相关的所有类/方法都是私有的,无法从我的代码中访问

我的代码:

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); 
CompilerOptions opt=new CompilerOptions();
//决定模式
编译级别。高级优化。设置选项用于编译级别(opt);
opt.prettyPrint=false;
编译器.setLoggingLevel(Level.OFF);
编译器压缩器=新编译器();
压缩机。禁用螺纹();
列表输入=。。。;
列表外部=。。。;
compile(外部、输入、opt);
我会说

opt.setCreateNameMapFiles(true)

您可以使用以下选项:variable\u map\u output\u file filename,与道具类似

请注意:标志变量\u map\u output\u file和create\u name\u map\u files不能同时使用。

compile”函数返回一个结果对象,其中包含变量(variableMap)和属性(propertyMap)重命名映射。这些属性包含可以序列化的VariableMap对象:

Result result = compiler.compiler(...);
result.variableMap.save(varmapPath);
result.propertyMap.save(propmapPath);

CommandLineRunner.java在标题中获得了执行此操作的说明。。但也许有人知道的更多。。