2015-03-17 23:15:13 +00:00
|
|
|
import org.apache.tools.ant.filters.ReplaceTokens
|
|
|
|
|
2015-02-17 22:45:18 +00:00
|
|
|
apply plugin: "groovy"
|
|
|
|
apply plugin: "maven"
|
2015-02-20 23:23:30 +00:00
|
|
|
apply plugin: "war"
|
2015-03-03 22:27:45 +00:00
|
|
|
apply plugin: "jetty"
|
2015-02-17 22:45:18 +00:00
|
|
|
|
2015-03-17 23:15:13 +00:00
|
|
|
apply from: 'shell.gradle'
|
|
|
|
|
2015-02-17 22:45:18 +00:00
|
|
|
group = "com.jdbernard"
|
2015-03-17 23:15:13 +00:00
|
|
|
|
|
|
|
version = new ProjectVersion()
|
|
|
|
|
|
|
|
// webAppDirName = "build/webapp/main"
|
2015-02-17 22:45:18 +00:00
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenLocal()
|
|
|
|
mavenCentral() }
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
compile 'ch.qos.logback:logback-classic:1.1.2'
|
2015-03-03 02:36:28 +00:00
|
|
|
compile 'ch.qos.logback:logback-core:1.1.2'
|
2015-02-20 07:08:17 +00:00
|
|
|
compile 'com.impossibl.pgjdbc-ng:pgjdbc-ng:0.3'
|
2015-03-03 02:36:28 +00:00
|
|
|
compile 'com.lambdaworks:scrypt:1.4.0'
|
|
|
|
compile 'com.zaxxer:HikariCP-java6:2.3.2'
|
|
|
|
compile 'javax:javaee-api:7.0'
|
|
|
|
compile 'javax.ws.rs:javax.ws.rs-api:2.0.1'
|
2015-03-07 20:16:52 +00:00
|
|
|
compile 'joda-time:joda-time:2.7'
|
2015-03-03 02:36:28 +00:00
|
|
|
compile 'org.codehaus.groovy:groovy-all:2.3.6'
|
|
|
|
compile 'org.slf4j:slf4j-api:1.7.10'
|
2015-02-20 23:23:30 +00:00
|
|
|
runtime 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.3.2'
|
2015-02-20 07:08:17 +00:00
|
|
|
runtime 'org.glassfish.jersey.containers:jersey-container-servlet:2.16'
|
2015-03-03 02:36:28 +00:00
|
|
|
runtime 'org.glassfish.jersey.media:jersey-media-json-jackson:2.16'
|
|
|
|
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
|
2015-02-17 22:45:18 +00:00
|
|
|
|
2015-03-03 22:27:45 +00:00
|
|
|
testCompile 'com.jdbernard:jdb-util:3.4'
|
2015-02-17 22:45:18 +00:00
|
|
|
testCompile 'junit:junit:4.12'
|
2015-03-03 22:27:45 +00:00
|
|
|
testRuntime 'com.h2database:h2:1.4.186'
|
2015-02-20 07:08:17 +00:00
|
|
|
|
2015-02-17 22:45:18 +00:00
|
|
|
}
|
2015-03-03 02:36:28 +00:00
|
|
|
|
2015-03-17 23:15:13 +00:00
|
|
|
war {
|
|
|
|
from "resources/webapp"
|
2015-03-18 00:46:50 +00:00
|
|
|
from "build/webapp"
|
2015-03-17 23:15:13 +00:00
|
|
|
filter(ReplaceTokens, tokens: [version: version])
|
|
|
|
rename '(.+)(\\..*(css|js))', '$1-' + version + '$2'
|
2015-03-18 00:46:50 +00:00
|
|
|
version = project.version.releaseVersion
|
|
|
|
webInf { from 'resources/main/WEB-INF' }
|
2015-03-23 09:09:28 +00:00
|
|
|
exclude "**/.*.swp", "**/.sass-cache"
|
2015-03-17 23:15:13 +00:00
|
|
|
}
|
2015-03-03 22:27:45 +00:00
|
|
|
|
2015-03-07 20:20:06 +00:00
|
|
|
test { testLogging { events 'failed' } }
|
2015-03-03 22:27:45 +00:00
|
|
|
|
|
|
|
task testWar(type: War) {
|
|
|
|
from 'resources/webapp'
|
2015-03-17 23:15:13 +00:00
|
|
|
filter(ReplaceTokens, tokens: [version: version])
|
|
|
|
rename '(.+)(\\..*(css|js))', '$1-' + version + '$2'
|
2015-03-18 00:46:50 +00:00
|
|
|
version = project.version.releaseVersion
|
|
|
|
webInf { from 'resources/test/WEB-INF' }
|
2015-03-03 22:27:45 +00:00
|
|
|
classifier 'test' }
|
2015-03-03 03:27:05 +00:00
|
|
|
|
2015-03-18 00:46:50 +00:00
|
|
|
task compileScss(
|
|
|
|
group: 'build',
|
|
|
|
description: 'Compile SCSS files into CSS.',
|
|
|
|
type: Exec
|
|
|
|
) {
|
|
|
|
executable "scss"
|
|
|
|
args "--update", "src/main/webapp/css:build/webapp/css"
|
|
|
|
}
|
|
|
|
|
|
|
|
war.dependsOn compileScss
|
|
|
|
testWar.dependsOn compileScss
|
|
|
|
|
2015-03-17 23:15:13 +00:00
|
|
|
// ## Build Versioning task
|
|
|
|
task incrementBuildNumber(
|
|
|
|
group: 'versioning',
|
|
|
|
description: "Increment the project's build number."
|
|
|
|
) << { ++version.build }
|
|
|
|
|
|
|
|
task incrementMinorNumber(
|
|
|
|
group: 'versioning',
|
|
|
|
description: "Increment the project's minor version number."
|
|
|
|
) << { ++version.minor }
|
|
|
|
|
|
|
|
task incrementMajorNumber(
|
|
|
|
group: 'versioning',
|
|
|
|
description: "Increment the project's major version number."
|
|
|
|
) << { ++version.major }
|
|
|
|
|
|
|
|
task markReleaseBuild(
|
|
|
|
group: 'versioning',
|
|
|
|
description: "Mark this version of the project as a release version."
|
|
|
|
) << { version.release = true }
|
|
|
|
|
2015-03-18 00:46:50 +00:00
|
|
|
war.dependsOn << incrementBuildNumber
|
|
|
|
testWar.dependsOn << incrementBuildNumber
|
2015-03-17 23:15:13 +00:00
|
|
|
|
2015-03-03 03:27:05 +00:00
|
|
|
// ## Custom tasks for local deployment
|
|
|
|
|
2015-03-03 02:36:28 +00:00
|
|
|
task deployLocal(dependsOn: ['build']) << {
|
2015-03-18 00:46:50 +00:00
|
|
|
def warName = "${project.name}-${version.releaseVersion}.war"
|
2015-03-03 02:36:28 +00:00
|
|
|
def jettyHome = System.getenv("JETTY_HOME")
|
|
|
|
def deployedWar = new File("$jettyHome/webapps/$warName")
|
|
|
|
|
|
|
|
if (deployedWar.exists()) deployedWar.delete();
|
|
|
|
copy {
|
|
|
|
from "build/libs"
|
|
|
|
into "$jettyHome/webapps"
|
|
|
|
include warName } }
|
|
|
|
|
|
|
|
task killJettyLocal() << {
|
|
|
|
def pidFile = new File(System.properties['user.home'] + "/temp/jetty.pid")
|
|
|
|
|
2015-03-17 23:15:13 +00:00
|
|
|
println "Killing old Jetty instance."
|
|
|
|
shell_("sh", "-c", 'kill $(jps -l | grep start.jar | cut -f 1 -d " ")') }
|
2015-03-03 02:36:28 +00:00
|
|
|
|
|
|
|
task localJetty(dependsOn: ['killJettyLocal', 'deployLocal']) << {
|
2015-03-17 23:15:13 +00:00
|
|
|
spawn(["java", "-jar", "start.jar"], new File(jettyHome)) }
|
|
|
|
|
|
|
|
// ## Project Version
|
|
|
|
class ProjectVersion {
|
|
|
|
|
|
|
|
private File versionFile
|
2015-03-03 02:36:28 +00:00
|
|
|
|
2015-03-17 23:15:13 +00:00
|
|
|
int major
|
|
|
|
int minor
|
|
|
|
int build
|
|
|
|
boolean release
|
|
|
|
|
|
|
|
public ProjectVersion() { this(new File('version.properties')) }
|
|
|
|
|
|
|
|
public ProjectVersion(File versionFile) {
|
|
|
|
this.versionFile = versionFile
|
|
|
|
|
|
|
|
if (!versionFile.exists()) {
|
|
|
|
versionFile.createNewFile()
|
|
|
|
this.major = this.minor = this.build = 0
|
|
|
|
this.save() }
|
|
|
|
|
|
|
|
else this.load() }
|
|
|
|
|
|
|
|
@Override String toString() { "$major.$minor${release ? '' : '-build' + build}" }
|
|
|
|
|
2015-03-18 00:46:50 +00:00
|
|
|
public String getReleaseVersion() { "$major.$minor" }
|
|
|
|
|
2015-03-23 09:09:28 +00:00
|
|
|
public void setRelease(boolean release) { this.release = release; save() }
|
|
|
|
|
2015-03-17 23:15:13 +00:00
|
|
|
public void setMajor(int major) {
|
|
|
|
this.major = major; minor = build = 0; release = false; save() }
|
|
|
|
|
|
|
|
public void setMinor(int minor) {
|
|
|
|
this.minor = minor; build = 0; release = false; save() }
|
|
|
|
|
|
|
|
public void setBuild(int build) { this.build = build; save() }
|
|
|
|
|
|
|
|
private void save() {
|
|
|
|
def props = new Properties()
|
|
|
|
versionFile.withInputStream { props.load(it) }
|
|
|
|
["major", "minor", "build"].each { props[it] = this[it].toString() }
|
|
|
|
props["version.release"] = release.toString()
|
|
|
|
versionFile.withOutputStream { props.store(it, "") } }
|
|
|
|
|
|
|
|
private void load() {
|
|
|
|
def props = new Properties()
|
|
|
|
versionFile.withInputStream { props.load(it) }
|
|
|
|
["major", "minor", "build"].each {
|
|
|
|
this[it] = props[it] ? props[it] as int : 0 }
|
|
|
|
release = Boolean.parseBoolean(props["version.release"]) }
|
|
|
|
}
|