2016-07-23 20:02:52 -05:00
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
mavenLocal()
|
|
|
|
mavenCentral()
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
classpath 'net.sourceforge.fmpp:fmpp:0.9.15+'
|
|
|
|
classpath 'com.google.javascript:closure-compiler:v20140730+'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
id "com.moowork.node" version "0.11"
|
|
|
|
}
|
|
|
|
|
2016-07-23 23:14:14 -05:00
|
|
|
group = "com.jdbernard"
|
|
|
|
version = "1.0.0"
|
2016-07-23 20:02:52 -05:00
|
|
|
|
|
|
|
task clean(
|
|
|
|
group: 'build',
|
|
|
|
description: 'Deletes the build directory.',
|
|
|
|
type: Delete) {
|
|
|
|
delete 'build'
|
|
|
|
}
|
|
|
|
|
|
|
|
task cleanAll(
|
|
|
|
group: 'build',
|
|
|
|
description: 'Deletes the build directory and locally installed libraries.',
|
|
|
|
type: Delete,
|
|
|
|
dependsOn: clean) {
|
|
|
|
delete 'node_modules', 'bower_components'
|
|
|
|
}
|
|
|
|
|
|
|
|
task compileScss(
|
|
|
|
group: 'build',
|
|
|
|
description: 'Compile SCSS files into CSS.',
|
|
|
|
type: Exec) {
|
2016-07-23 23:14:14 -05:00
|
|
|
inputs.file("src/main/scss/spike-wars.scss")
|
2016-07-23 20:02:52 -05:00
|
|
|
outputs.dir("build/webroot/css")
|
|
|
|
executable "scss"
|
2016-07-23 23:14:14 -05:00
|
|
|
args "--update", "src/main/scss/spike-wars.scss:build/webroot/css/spike-wars-${version}.css", "-I", "src/main/scss-lib", "-t", "compressed"
|
2016-07-23 20:02:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
task bowerInstall(
|
|
|
|
group: 'build',
|
|
|
|
description: 'Install bower components.',
|
|
|
|
type: NodeTask) {
|
|
|
|
outputs.dir('bower_components')
|
|
|
|
script = file('node_modules/bower/bin/bower')
|
|
|
|
args = ['install']
|
|
|
|
}
|
|
|
|
|
|
|
|
task flowCheck(
|
|
|
|
group: 'build',
|
|
|
|
description: 'Run the Flow JavaScript type checker.',
|
|
|
|
dependsOn: [npmInstall/*, bowerInstall*/],
|
|
|
|
type: NodeTask) {
|
|
|
|
inputs.dir('src/main/js')
|
|
|
|
script = file('node_modules/flow-bin/cli.js')
|
|
|
|
}
|
|
|
|
|
|
|
|
task browserify(
|
|
|
|
group: 'build',
|
2016-07-23 23:14:14 -05:00
|
|
|
dependsOn: [npmInstall, flowCheck],
|
2016-07-23 20:02:52 -05:00
|
|
|
type: NodeTask) {
|
|
|
|
|
|
|
|
inputs.dir('src/main/js/${project.name}.js')
|
|
|
|
outputs.file('build/webroot/js/${project.name}-${project.version}.js')
|
|
|
|
|
|
|
|
doFirst { file('build/webroot/js').mkdirs() }
|
|
|
|
script = file('node_modules/browserify/bin/cmd.js')
|
|
|
|
args = ['-t', 'babelify', '-o', "build/webroot/js/${project.name}-${project.version}.js",
|
|
|
|
"src/main/js/${project.name}.js"]
|
|
|
|
}
|
|
|
|
|
|
|
|
task minifyJavaScript(
|
|
|
|
group: 'build',
|
|
|
|
description: 'Compile JavaScript files into minified output files.',
|
|
|
|
dependsOn: browserify,
|
|
|
|
type: JavaExec) {
|
|
|
|
|
|
|
|
inputs.dir('build/webroot/js/${project.name}-${project.version}.js')
|
|
|
|
outputs.file('build/webroot/js/${project.name}-${project.version}.min.js')
|
|
|
|
|
|
|
|
classpath = project.buildscript.configurations.classpath
|
|
|
|
main = 'com.google.javascript.jscomp.CommandLineRunner'
|
|
|
|
def argsArr = []
|
|
|
|
argsArr << '--compilation_level=SIMPLE_OPTIMIZATIONS'
|
|
|
|
argsArr << "--js_output_file=build/webroot/js/${project.name}-${project.version}.min.js"
|
|
|
|
argsArr << "build/webroot/js/${project.name}-${project.version}.js"
|
|
|
|
|
|
|
|
args argsArr
|
|
|
|
}
|
|
|
|
|
|
|
|
task compileHtml(
|
|
|
|
group: 'build',
|
|
|
|
description: 'Compile HTML templates into rendered output.') {
|
|
|
|
inputs.dir('src/main/html')
|
|
|
|
outputs.dir('build/webroot')
|
|
|
|
} << {
|
|
|
|
|
|
|
|
ant.taskdef(name: 'fmpp', classname:'fmpp.tools.AntTask',
|
|
|
|
classpath: project.buildscript.configurations.classpath.asPath)
|
|
|
|
|
|
|
|
ant.fmpp(sourceRoot: "src/main/html", outputRoot: "build/webroot",
|
|
|
|
excludes: "templates/**,**/*.sw?") {
|
|
|
|
|
|
|
|
data("""version: ${project.version}""")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task copyResources(
|
|
|
|
group: 'build',
|
|
|
|
description: 'Copy static resources into the build directory.',
|
|
|
|
type: Copy) {
|
|
|
|
|
|
|
|
// Third party resources not bundled by Browserify
|
|
|
|
from "path/to/resource/dir"
|
|
|
|
into "build/webroot"
|
|
|
|
}
|
|
|
|
|
|
|
|
task compile(
|
|
|
|
group: 'build',
|
|
|
|
description: 'Compile all webapp resources',
|
2016-07-23 23:14:14 -05:00
|
|
|
dependsOn: [copyResources, compileScss, browserify, minifyJavaScript, compileHtml])
|
2016-07-23 20:02:52 -05:00
|
|
|
|
|
|
|
task assemble(
|
|
|
|
group: 'build',
|
|
|
|
description: 'Assembles the outputs of this project.',
|
|
|
|
dependsOn: compile,
|
|
|
|
type: Zip) {
|
|
|
|
|
|
|
|
from "build/webroot"
|
|
|
|
destinationDir = file("build")
|
|
|
|
baseName = project.name
|
|
|
|
version = project.version
|
|
|
|
extension = 'zip'
|
|
|
|
}
|
|
|
|
|
|
|
|
task build(
|
|
|
|
group: 'build',
|
|
|
|
description: 'Assembles and tests the outputs of this project.',
|
|
|
|
dependsOn: [assemble]) << {
|
|
|
|
|
|
|
|
}
|