문서의 이전 판입니다!
void minifyJsFile(final Set<File> inputFiles, final Set<File> externsFiles, final File outputFile, final CompilerOptions options, final String warningLevel, final String compilationLevel) { Compiler compiler = new Compiler() CompilationLevel.valueOf(compilationLevel).setOptionsForCompilationLevel(options) WarningLevel level = WarningLevel.valueOf(warningLevel) level.setOptionsForWarningLevel(options) List<JSSourceFile> externs = CommandLineRunner.getDefaultExterns() if (externsFiles.size()) { externs.addAll(externsFiles.collect() { JSSourceFile.fromFile(it) }) } List<JSSourceFile> inputs = new ArrayList<JSSourceFile>() inputFiles.each { inputFile -> inputs.add(JSSourceFile.fromFile(inputFile)) } Result result = compiler.compile(externs, inputs, options) if (result.success) { outputFile.write(compiler.toSource()) } else { result.errors.each { println "${it.sourceName}:${it.lineNumber} - ${it.description}" } } }