Skip to content

Instantly share code, notes, and snippets.

@ramrrr
Created August 26, 2014 08:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramrrr/d9156a096a5b21610c0b to your computer and use it in GitHub Desktop.
Save ramrrr/d9156a096a5b21610c0b to your computer and use it in GitHub Desktop.
build.gradle
buildscript {
repositories {
maven { url 'http://repo.jfrog.org/artifactory/gradle-plugins' }
}
dependencies {
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.16')
}
}
apply plugin: 'git'
allprojects {
apply plugin: 'idea'
apply plugin: 'java'
group = 'no.ums'
version = '3.0'
if (project.hasProperty("versionPostfix")) {
version = "$version-$versionPostfix"
}
tasks.withType(Compile) {
options.encoding = 'UTF-8'
}
configurations.compile.transitive = true
sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceSets {
webtests {
java.srcDirs = ["src/test-web/java"]
resources.srcDirs = ["src/test-web/resources"]
}
inttest {
java.srcDirs = ["src/test-integration/java"]
resources.srcDirs = ["src/test-integration/resources"]
}
}
dependencies {
webtestsCompile sourceSets.main.output
webtestsCompile configurations.testCompile
webtestsCompile sourceSets.test.output
webtestsRuntime configurations.testRuntime
inttestCompile sourceSets.main.output
inttestCompile configurations.testCompile
inttestCompile sourceSets.test.output
inttestRuntime configurations.testRuntime
}
idea.module {
testSourceDirs += sourceSets.webtests.java.srcDirs
testSourceDirs += sourceSets.webtests.resources.srcDirs
scopes.TEST.plus += configurations.webtestsCompile
testSourceDirs += sourceSets.inttest.java.srcDirs
testSourceDirs += sourceSets.inttest.resources.srcDirs
scopes.TEST.plus += configurations.inttestCompile
inheritOutputDirs = false
outputDir = sourceSets.main.output.classesDir
testOutputDir = sourceSets.test.output.classesDir
}
task integrationTest(type: Test, dependsOn: jar) {
testClassesDir = sourceSets.inttest.output.classesDir
classpath = sourceSets.inttest.runtimeClasspath
systemProperties['jar.path'] = jar.archivePath
}
test {
forkEvery 5
minHeapSize = "128m"
maxHeapSize = "512m"
jvmArgs '-XX:MaxPermSize=256m'
jvmArgs '-XX:+HeapDumpOnOutOfMemoryError'
}
compileJava {
options.compilerArgs << "-Werror"
options.fork = true
options.forkOptions.executable = "javac"
}
}
subprojects {
apply plugin: 'eclipse'
apply plugin: 'jacoco'
apply plugin: 'findbugs-ums'
apply plugin: 'artifactory'
apply plugin: 'maven'
apply plugin: 'checkstyle'
project.ext.guavaVersion = "15.0"
project.ext.eclipselinkVersion = "2.3.0"
project.ext.guiceVersion = "3.0"
project.ext.slf4jVersion = "1.7.4"
project.ext.springVersion = "3.2.2.RELEASE"
project.ext.springSecurityVersion = "3.1.3.RELEASE"
project.ext.springSocialVersion = "1.1.0.M2"
project.ext.aspectjVersion = "1.7.2"
project.ext.typesafeConfigVersion = "1.0.0"
project.ext.backboneFacadeVersion = "1.1.0-SNAPSHOT"
project.ext.jettyVersion = "9.0.7.v20131107"
project.ext.apacheCxfVersion = "2.6.2"
project.ext.thymeleafVersion = "2.0.15"
project.ext.jacksonVersion = "2.4.+"
project.ext.elastisearchVersion = "0.90.7"
project.ext.jacocoVersion = '0.6.0.201210061924'
checkstyle.configFile = file("$rootDir/etc/checkstyle/checkstyle.xml")
checkstyle.configProperties['configLoc'] = "$rootDir/etc/checkstyle/"
checkstyle.sourceSets = [sourceSets.main]
checkstyle.ignoreFailures = true
repositories {
maven {
credentials {
username 'ums'
password 'artifactory'
}
url "http://umscom.artifactoryonline.com/umscom/libs-releases"
}
maven {
credentials {
username 'ums'
password 'artifactory'
}
url "http://umscom.artifactoryonline.com/umscom/libs-snapshots"
}
}
configurations {
antConfig
}
// Force the resources output dir to be the same as the classesDir, otherwise tests fails
// as EclipseLink looks for the persistence.xml file.
sourceSets.main {
output.resourcesDir = output.classesDir
}
eclipse.classpath {
plusConfigurations += configurations.webtestsCompile
plusConfigurations += configurations.inttestCompile
file {
whenMerged { classpath ->
classpath.entries.removeAll {
it.path.startsWith(buildDir.absolutePath)
}
}
}
}
dependencies {
checkstyle 'com.puppycrawl.tools:checkstyle:5.6'
compile "findbugs:annotations:1.0.0"
compile 'org.apache.commons:commons-lang3:3.2.1'
testCompile 'org.hamcrest:hamcrest-library:1.1'
testCompile 'org.mockito:mockito-core:1.9.0'
testCompile "junit:junit:4.10"
testCompile "org.jmock:jmock:2.5.1"
}
task buildDir << {
new File("${project.buildDir}").mkdirs()
}
tasks.buildDir.inputs.file project.buildFile
tasks.buildDir.outputs.dir project.buildDir
tasks.buildDir.description = "Creates the build output directory"
tasks.buildDir.group = "Help"
jacocoTestReport {
reports {
csv.enabled false
html.enabled true
xml.enabled true
xml.destination "${project.reporting.baseDir.absolutePath}/jacoco/jacoco.xml"
}
sourceDirectories = files(sourceSets.main.java.srcDirs)
}
if (project.hasProperty("extraCheck")) {
// Add findbugs and jacoco xml tasks to check
check.dependsOn "findbugs"
check.dependsOn integrationTest
check.dependsOn jacocoTestReport
}
eclipseProject.doLast {
def chkRoot = file("$rootDir/etc/checkstyle")
def chkFile = file("$chkRoot/checkstyle.xml")
def name = "UMS Heimdall Check"
def desc = "UMS Checkstyle generated by gradle"
new File("$projectDir/.checkstyle").withWriter { out ->
def xml = new groovy.xml.MarkupBuilder(out)
xml.'fileset-config'('file-format-version': "1.2.0", 'simple-config': "false", 'sync-formatter': "false") {
'local-check-config'(name: name, location: chkFile, type: "external", description: desc) {
'property'(name: "configLoc", value: "$chkRoot/")
'additional-data'(name: "protect-config-file", value: "false")
}
fileset(name: "JavaOnly", enabled: "true", 'check-config-name': name, local: "true") {
'file-match-pattern'('match-pattern': "src/main/java/.*.java", 'include-pattern': "true")
}
}
}
}
}
idea {
project {
ipr {
withXml { provider ->
provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@vcs = 'Git'
provider.node.component.findAll { it.@name == "CheckStyle-IDEA" }.each {
provider.node.remove(it)
}
def configMap = provider.node
.appendNode("component", [name: "CheckStyle-IDEA"])
.appendNode("option", [name: "configuration"])
.appendNode("map")
configMap.appendNode("entry", [key: "active-configuration", value: "FILE:$rootDir/etc/checkstyle/checkstyle.xml:Heimdall"])
configMap.appendNode("entry", [key: "check-nonjava-files", value: "false"])
configMap.appendNode("entry", [key: "check-test-classes", value: "false"])
configMap.appendNode("entry", [key: "location-0", value: "FILE:$rootDir/etc/checkstyle/checkstyle.xml:Heimdall"])
configMap.appendNode("entry", [key: "property-0.config_loc", value: ""])
configMap.appendNode("entry", [key: "thirdparty-classpath", value: ""])
}
}
}
}
idea {
project {
ipr {
withXml { provider ->
provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@vcs = 'Git'
}
}
}
}
evaluationDependsOnChildren()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment