사용자 도구

사이트 도구


gradle:javascript

문서의 이전 판입니다!


Gradle Javascript Plugin

gradle-js-plugin

gradle-jslint-plugin

Closure Compiler API

    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}"
            }
        }
    }
gradle/javascript.1350977008.txt.gz · 마지막으로 수정됨: 2012/10/23 16:23 저자 kwon37xi