I am making a simple website and am writing a gradle build script that will do things like lint and minify css/html/js.
At this stage I have just done the CSS which is working, but is just in an initial unstructured format
defaultTasks 'loadToOutput', 'minCSS' ,'deployToSite'
task loadToOutput(type: Copy) {
from 'src/web'
into 'output'
}
task compileSCSS(type: Exec) {
commandLine 'sass', '/home/alistair/dev/personalwebsite/output/style/main.scss', '/home/alistair/dev/personalwebsite/output/style/main.css'
}
task csslint(type: Exec, dependsOn: compileSCSS) {
def cmdLineOptions = ["--errors=adjoining-classes,box-model,box-sizing,compatible-vendor-prefixes,display-property-grouping,duplicate-background-images,duplicate-properties,empty-rules,errors,fallback-colors,floats,font-faces,font-sizes,gradients,import,important,known-properties,outline-none,overqualified-elements,qualified-headings,regex-selectors,rules-count,shorthand,text-indent,unique-headings,universal-selector,unqualified-attributes,vendor-prefix,zero-units"]
def cssDir = '/home/alistair/dev/personalwebsite/output/style'
commandLine = ["csslint"] + cmdLineOptions + [cssDir]
}
task minCSS(type: Exec, dependsOn: csslint) {
commandLine 'csso', '/home/alistair/dev/personalwebsite/output/style/main.css', '/home/alistair/dev/personalwebsite/output/style/main.css'
}
task deployToSite(type: Copy) {
from 'output'
into '/var/www/personalwebsite'
}
What I want to do is group the CSS tasks in a bit of a cleaner way. eg
task CSS {
compile
lint
minify
}
However, the only way I can figure out how to do this is to have a separate build file which contains the CSS project, which is a bit excessive for my current needs. Is there a simple/recommended way I can encapsulate tasks into a group and just execute the group so to speak?
(There are great reference docs on gradle, but very little cookbook/example/best practice info :/)
The solution: