Newer
Older
apply plugin: 'asciidoctor'
apply plugin: 'jetty'
apply plugin: 'vagrant'
import org.apache.tools.ant.filters.FixCrLfFilter
import org.apache.tools.ant.filters.ReplaceTokens
group = 'it.unibz.inf.isochrone'
version = '0.2-SNAPSHOT'
description = 'PhD project of Nikolaus Krismer'

User expired
committed
def getDate() {
def date = new Date()
def formattedDate = date.format('yyyyMMdd')
return formattedDate

User expired
committed
}
// vagrantDirString = System.properties['user.home'] + '/vagrantboxes/' + project.name.toLowerCase()
// vagrantDirString = '/media/data/VMs/vagrantboxes/' + project.name.toLowerCase()
// vagrantDir = file("$vagrantDirString")
vagrantDir = getProjectDir()
if (version.equalsIgnoreCase('unspecified')) {
version = defaultVersion
} else if (!version.matches(~/[0-9\.]*(-SNAPSHOT)?/)) {
println "Invalid version number '$version' given. Falling back to default!"
version = defaultVersion
}
if (version.endsWith('-SNAPSHOT')) {
println "Building SNAPSHOT version $version"
} else {
isRelease = true;
println "Building RELEASE version $version"
}
mavenCentral()
maven { url "http://maven.geo-solutions.it" }
}
buildscript {
apply from: 'http://www.krismer.de/files/checkstyle.gradle'
repositories {
jcenter()
maven { url 'http://dl.bintray.com/content/aalmiray/asciidoctor'}
}
classpath 'org.gradle.api.plugins:gradle-vagrant-plugin:0.2'
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:0.7.0'
}
providedCompile group: 'javax.servlet', name: 'javax.servlet-api', version:'3.1.0'
providedCompile group: 'javax.websocket', name: 'javax.websocket-api', version:'1.0'
compile group: 'commons-dbutils', name: 'commons-dbutils', version:'1.2'
compile group: 'commons-httpclient', name: 'commons-httpclient', version:'3.1'
compile(group: 'it.geosolutions', name: 'geoserver-manager', version:'1.5.2') {
exclude(module: 'jcl-over-slf4j')
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.3.0'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.3.0'
compile group: 'com.google.code.findbugs', name: 'annotations', version: '2.0.3'
compile group: 'com.tngtech.java', name: 'config-builder', version: '1.1'
compile(group: 'org.postgis', name: 'postgis-jdbc', version:'1.3+') {
exclude(module: 'postgis-stubs')
}
compile group: 'org.postgresql', name: 'postgresql', version:'9.3-1100-jdbc41'
runtime 'org.slf4j:jcl-over-slf4j:1.7.5'
runtime 'ch.qos.logback:logback-classic:1.0.13'
tasks.withType(Compile) {
// adds support for compiler warnings generation
options.compilerArgs << '-Xlint'
}
asciidoctor {
backend = 'html5'
sourceDir = file('doc')
outputDir = file("$buildDir/docs/asciidoctor")
showViolations = false
}
eclipse {
project {
buildCommand 'net.sf.eclipsecs.core.CheckstyleBuilder'
natures = [
'net.sf.eclipsecs.core.CheckstyleNature',
'org.springsource.ide.eclipse.gradle.core.nature',
'org.eclipse.jem.workbench.JavaEMFNature',
'org.eclipse.wst.common.modulecore.ModuleCoreNature',
'org.eclipse.wst.common.project.facet.core.nature',
'org.eclipse.jdt.core.javanature',
'org.eclipse.wst.jsdt.core.jsNature'
]
file {
withXml { xmlProvider ->
Node project = xmlProvider.asNode()
Node filteredResources = project.appendNode('filteredResources');
Node filterGradle = filteredResources.appendNode('filter')
filterGradle.appendNode('id', 1392635165065)
filterGradle.appendNode('name', '')
filterGradle.appendNode('type', 30)
Node matcherGradle = filterGradle.appendNode('matcher')
matcherGradle.appendNode('id', 'org.eclipse.ui.ide.multiFilter')
matcherGradle.appendNode('arguments', '1.0-name-matches-false-false-.gradle')
Node filterVagrant = filteredResources.appendNode('filter')
filterVagrant.appendNode('id', 1392635165131)
filterVagrant.appendNode('name', '')
filterVagrant.appendNode('type', 30)
Node matcherVagrant = filterVagrant.appendNode('matcher')
matcherVagrant.appendNode('id', 'org.eclipse.ui.ide.multiFilter')
matcherVagrant.appendNode('arguments', '1.0-name-matches-false-false-.vagrant')
}
}
contextPath = '/isochrone'
deployName = 'isochrone'
// when tomcat 8 becomes usable in eclipse this jst.web version should be set to 3.1
//facet name: 'jst.web', version: '3.1'
facet name: 'jst.web', version: '3.0'
facet name: 'wst.jsdt.web', version: '1.0'
eclipse.classpath.file {
// See: http://stackoverflow.com/questions/12836089/why-is-eclipse-not-attaching-3rd-party-libs-source-files-to-a-wtp-faceted-gradle
// Chnanges eclipse classpath entries; otherwise no sources for 3rd party jars are shown
withXml { xml ->
def node = xml.asNode()
node.remove( node.find { it.@path == 'org.eclipse.jst.j2ee.internal.web.container' } )
node.appendNode( 'classpathentry', [ kind: 'con', path: 'org.eclipse.jst.j2ee.internal.web.container', exported: 'true'])
}
// See: http://forums.gradle.org/gradle/topics/eclipse_wtp_deploys_testcode_to_server_example_provided
// Sets output folders for compiled classes and resources... otherwise test classes/resources would be deployed to wtp server
whenMerged { cp ->
cp.entries.findAll { it.path.startsWith("src/main/") }*.output = "bin"
cp.entries.findAll { it.path.startsWith("src/test/") }*.output = "bin-test"
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact javadocJar
artifact sourcesJar
artifact staticJar
artifact war
}
}
repositories {
maven {
credentials {
username repositoryUsername
password repositoryPassword
}
url repositoryPrefix + "${isRelease ? 'releases' : 'snapshots'}"
}
test {
useTestNG()
options {
listeners << 'org.testng.reporters.XMLReporter'
}
//turn off Gradle's HTML report to avoid replacing the
//reports generated by TestNG library:
reports.junitXml.enabled = false
reports.html.enabled = false
test.doFirst {
// TestNG XMLReporter does not create reportDir (but would fail without it)
if (!project.testReportDir.isDirectory()) {
project.testReportDir.mkdirs()
}
}
boxDir = vagrantDir
provider = 'virtualbox'
}
vagrantDestroy.doFirst {
if (!vagrantDir.isDirectory()) {
throw new StopExecutionException()
}
}
// Custom task definitions
task cleanTestResults(type: Delete) {
// We only need the test reports... not the binary results
delete project.testResultsDir
}
task javadocJar(type: Jar, dependsOn: javadoc) {
description = 'Builds a jar file including javadoc'
from javadoc.destinationDir
classifier "javadoc"
}
task jsDoc(type:com.eriwen.gradle.js.tasks.JsDocTask) {
source = fileTree(dir: 'src/main/webapp/js', include: '**/*.js', excludes: ['**/*.min.js', 'lib/**'])
destinationDir = file("${buildDir}/docs/jsdoc")
}
task jsHint(type:com.eriwen.gradle.js.tasks.JsHintTask) {
jshint.options = [browser: true, expr: true, jquery: true, latedef: 'nofunc', quotmark: 'single', unused: true, undef: true, wsh: true]
jshint.predef = ['$': false, 'define': false, 'google': false, 'require': false]
source = fileTree(dir: 'src/main/webapp/js', include: '**/*.js', exclude: ['**/*.min.js', 'lib/**'])
dest = file("${buildDir}/reports/jshint/main.xml")
reporter = 'checkstyle'
task sourcesJar(type: Jar, dependsOn: classes) {
description = 'Builds a jar file including sources'
from sourceSets.main.allSource
classifier "sources"
}
task staticJar(type: Jar) {
description = 'Builds a jar file including all libraries'
from sourceSets.main.output
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
manifest { attributes 'Main-Class': 'de.krismer.tnfp.TrackNumberFromPlaylist' }
classifier "static"
}
task testSimple(type: Test, dependsOn: testClasses) {
useTestNG()
jvmArgs '-Xmx4096m'
include '**/RunSimple*'
}
task vagrantExport(type: Zip) {
description = 'Builds an archive file that contains the files, needed to create the vagrant box'
from 'etc/vagrant'
appendix = ''
baseName = 'vagrantbox'
classifier = ''
version = getDate()
filter(ReplaceTokens, tokens: [db_username: 'myUser', db_password: 'myPassword'])
task vagrantPrepare << {
description = 'Prepares the vagrant environment (creates directory, copies Vagrantfile, ...)'
if (!vagrantDir.isDirectory()) {
println "Creating directory $vagrantDir and copying content"
sync {
from files('etc/vagrant')
into vagrantDir
filter(ReplaceTokens, tokens: [db_username: 'niko', db_password: 'secretPhdPassword#2014!'])
// task dependencies
tasks.jsDoc.dependsOn tasks.processResources
tasks.jsHint.dependsOn tasks.processResources
tasks.test.finalizedBy tasks.cleanTestResults
tasks.vagrantUp.dependsOn tasks.vagrantPrepare
// CI tasks
task jarAll(dependsOn: [jar, javadocJar, sourcesJar, staticJar])
task buildAll(dependsOn: [jarAll, build])
task daily(dependsOn: [asciidoctor, check, jsHint, javadoc, jsDoc, jarAll, war])