Initial skeleton and build process for Spike Wars.
This commit is contained in:
parent
62874c074e
commit
f27618fc0f
156
spike-wars/build.gradle
Normal file
156
spike-wars/build.gradle
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
group = ""
|
||||||
|
version = ""
|
||||||
|
|
||||||
|
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) {
|
||||||
|
inputs.dir("src/main/scss")
|
||||||
|
outputs.dir("build/webroot/css")
|
||||||
|
executable "scss"
|
||||||
|
args "--update", "src/main/scss:build/webroot/css", "-I", "src/main/scss-lib", "-t", "compressed"
|
||||||
|
}
|
||||||
|
|
||||||
|
task esLint(
|
||||||
|
group: 'check',
|
||||||
|
description: 'Run ESLint on JavaScript sources.',
|
||||||
|
dependsOn: npmInstall,
|
||||||
|
type: NodeTask) {
|
||||||
|
inputs.dir("src/main/js")
|
||||||
|
script = file('node_modules/eslint/bin/eslint')
|
||||||
|
args = ["src/main/js"]
|
||||||
|
}
|
||||||
|
|
||||||
|
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',
|
||||||
|
dependsOn: npmInstall,
|
||||||
|
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',
|
||||||
|
dependsOn: [jsHint, copyResources, compileScss, browserify, minifyJavaScript, compileHtml])
|
||||||
|
|
||||||
|
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]) << {
|
||||||
|
|
||||||
|
}
|
21
spike-wars/package.json
Normal file
21
spike-wars/package.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "spike-wars",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Spike Wars game.",
|
||||||
|
"main": "spike-wars.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "_git@git.jdb-labs.com:jdb/code-katas.git"
|
||||||
|
},
|
||||||
|
"author": "Jonathan Bernard <jdbernard@gmail.com>",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"babel-preset-es2015": "^6.9.0",
|
||||||
|
"babelify": "^7.3.0",
|
||||||
|
"browserify": "^13.0.1",
|
||||||
|
"flow-bin": "^0.29.0"
|
||||||
|
}
|
||||||
|
}
|
17
spike-wars/src/main/html/index.html
Normal file
17
spike-wars/src/main/html/index.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Spike Wars v${version}</title>
|
||||||
|
<meta charset='utf-8'/>
|
||||||
|
<meta name=viewport content='width=device-width, initial-scale=1.0'/>
|
||||||
|
<meta name="mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
|
||||||
|
<link href="css/spike-wars-${version}.css" type="text/css" rel="stylesheet"/>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Spike Wars!</h1>
|
||||||
|
<script type='application/javascript' src="js/spike-wars-${version}.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user