Skip to content
Newer
Older
100644 85 lines (70 sloc) 2.97 KB
ff5678b @eriwen Adding README and examples
authored
1 # Gradle Javascript Plugin! #
2 Aiming to be the *simplest* way to manage your Javascript in a build.
3
4 # Quick Start #
5 Wrangling your JS in a [Gradle](http://gradle.org) build is easy! Just add this to your *build.gradle* file:
6
418ae77 @eriwen Renaming processJs task to js
authored
7 ```groovy
ff5678b @eriwen Adding README and examples
authored
8 // Pull the plugin from a Maven Repo
9 buildscript {
10 repositories {
11 mavenCentral()
12 }
13 dependencies {
14 classpath 'com.eriwen:gradle-js-plugin:0.1'
15 }
16 }
17 // Invoke the plugin
18 apply plugin: 'js'
19
20 // Specify a collection of files to be combined, then minified and finally GZip compressed.
418ae77 @eriwen Renaming processJs task to js
authored
21 js {
ff5678b @eriwen Adding README and examples
authored
22 input = fileTree(dir: "${projectDir}/js", include: "**/*.js")
23 output = file("${buildDir}/combinedMinifiedAndGzipped.js")
24 }
418ae77 @eriwen Renaming processJs task to js
authored
25 ```
ff5678b @eriwen Adding README and examples
authored
26
418ae77 @eriwen Renaming processJs task to js
authored
27 **Need more than 1 set of files generated? Just add another *js* block:**
28
29 ```groovy
30 js {
ff5678b @eriwen Adding README and examples
authored
31 input = fileTree(dir: "${projectDir}/otherdir", includes: ["file1.js", "file2.js"])
32 output = file("${buildDir}/teenytiny.js")
33 }
418ae77 @eriwen Renaming processJs task to js
authored
34 ```
ff5678b @eriwen Adding README and examples
authored
35
36 **Want more fine-grained control or just want to combine, minify or zip your files?**
418ae77 @eriwen Renaming processJs task to js
authored
37
38 ```groovy
ff5678b @eriwen Adding README and examples
authored
39 // Combine JS files
40 combineJs {
41 input = fileTree(dir: "${projectDir}/js", include: "**/*.js")
42 output = file("${buildDir}/all.js")
43 }
44
45 // Minify with Google Closure Compiler
46 minifyJs {
47 input = file("${buildDir}/all.js")
48 output = file("${buildDir}/all-min.js")
49 warningLevel = 'QUIET'
50 }
51
52 // GZip it!
53 gzipJs {
54 input = file("${buildDir}/all-min.js")
55 output = input
56 }
418ae77 @eriwen Renaming processJs task to js
authored
57 ```
ff5678b @eriwen Adding README and examples
authored
58
59 # Available Tasks and Options #
418ae77 @eriwen Renaming processJs task to js
authored
60 ### combineJs ###
61 - input = [FileCollection](http://gradle.org/current/docs/javadoc/org/gradle/api/file/FileCollection.html) of files to merge
62 - output = File for combined output
63
64 ### minifyJs (Uses the [Google Closure Compiler](http://code.google.com/closure/compiler/)) ###
65 - input = File to minify
66 - output = File for minified output
67 - *(Optional)* compilationLevel = 'WHITESPACE_ONLY', 'SIMPLE_OPTIMIZATIONS' (default), or 'ADVANCED_OPTIMIZATIONS' (are you *hardcore*?)
68 - *(Optional)* warningLevel = 'QUIET', 'DEFAULT' (default), or 'VERBOSE'
69 - *(Optional)* options = [CompilerOptions](http://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/javascript/jscomp/CompilerOptions.java?r=1187) object
70
71 ### gzipJs ###
72 - input = File to compress
73 - output = File for compressed output
74
75 ### js ###
76 - input = File to minify
77 - output = File for minified output
78 - *(Optional)* compilationLevel = 'WHITESPACE_ONLY', 'SIMPLE_OPTIMIZATIONS' (default), or 'ADVANCED_OPTIMIZATIONS' (are you *hardcore*?)
79 - *(Optional)* warningLevel = 'QUIET', 'DEFAULT' (default), or 'VERBOSE'
80 - *(Optional)* options = [CompilerOptions](http://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/javascript/jscomp/CompilerOptions.java?r=1187) object
81
82 What, you want more? [Tell me then!](https://github.com/eriwen/gradle-js-plugin/issues)
fd62113 @eriwen Updating README
authored
83
84 # See Also #
85 The [Gradle CSS Plugin](https://github.com/eriwen/gradle-css-plugin)!
Something went wrong with that request. Please try again.