-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
141 lines (123 loc) · 4.54 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
buildscript {
repositories {
jcenter()
dependencies {
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '3.1.2')
classpath(group: 'net.saliman', name: 'gradle-cobertura-plugin', version: '2.2.8')
}
}
}
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'cobertura'
apply plugin: 'jacoco'
group = 'com.sysgears.example'
version = '1.0'
defaultTasks 'clean', 'build', 'test', 'uberJar'
def compatibilityVersion = 1.8
def springVersion = '4.2.2.RELEASE'
def mainClassName = 'com.sysgears.example.Main'
sourceCompatibility = compatibilityVersion
targetCompatibility = compatibilityVersion
repositories {
jcenter()
}
dependencies {
// Spring Framework Dependenices
compile "org.springframework:spring-beans:${springVersion}"
compile "org.springframework:spring-context:${springVersion}"
compile "org.springframework:spring-core:${springVersion}"
compile "org.springframework:spring-expression:${springVersion}"
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.+'
// JSR 330 annotation support
compile "javax.inject:javax.inject:1"
// Spring unit testing support
testCompile "org.springframework:spring-test:${springVersion}"
// Spock framework for unit testing
testCompile("org.spockframework:spock-core:1.0-groovy-2.4") {
exclude module: 'groovy-all'
}
testCompile("org.spockframework:spock-spring:1.0-groovy-2.4") {
exclude module: 'groovy-all'
}
// optional dependencies for using Spock
// only necessary if Hamcrest matchers are used
testCompile 'org.hamcrest:hamcrest-core:1.3'
// allows mocking of classes (in addition to interfaces)
testRuntime 'cglib:cglib-nodep:3.2.0'
// allows mocking of classes without default constructor (together with CGLIB)
testRuntime 'org.objenesis:objenesis:2.2'
// Groovy
compile 'org.codehaus.groovy:groovy-all:2.4.4'
}
test {
reports.html.enabled = true
// show standard out and standard error of the test JVM(s) on the console
testLogging.showStandardStreams = true
// set heap size for the test JVM(s)
minHeapSize = '128m'
maxHeapSize = '512m'
// set JVM arguments for the test JVM(s)
jvmArgs '-XX:MaxPermSize=256m'
// listen to events in the test execution lifecycle
beforeTest { descriptor ->
logger.lifecycle('Running test: ' + descriptor)
}
// listen to standard out and standard error of the test JVM(s)
onOutput { descriptor, event ->
logger.lifecycle('Test: ' + descriptor + ' produced standard out/err: ' + event.message)
}
}
// Creates executable standalone JAR file of the application
task uberJar(type: Jar, dependsOn:[':compileJava',':compileGroovy']) {
from files(sourceSets.main.output.classesDir)
from files(sourceSets.main.output.resourcesDir)
from(configurations.runtime.asFileTree.files.collect { zipTree(it) }) {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
manifest {
attributes 'Implementation-Title': 'Groovy app architecture example',
'Implementation-Version': version,
'Built-By': System.getProperty('user.name'),
'Built-Date': new Date(),
'Built-JDK': System.getProperty('java.version'),
'Main-Class': mainClassName
}
}
jacocoTestReport {
additionalSourceDirs = files(sourceSets.main.allSource.srcDirs)
sourceDirectories = files(sourceSets.main.allSource.srcDirs)
classDirectories = files(sourceSets.main.output)
executionData = files(jacocoTestReport.executionData)
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
}
}
//http://jdpgrailsdev.github.io/blog/2014/04/29/gradle_cobertura.html
//https://github.com/stevesaliman/gradle-cobertura-plugin/blob/master/usage.md
cobertura {
//fix cobertura version
//https://github.com/stevesaliman/gradle-cobertura-plugin/issues/72
//coberturaVersion = '2.1.1'
//coberturaVersion = '2.0.3'
coverageFormats = ['html', 'xml']
coverageIgnoreTrivial = true
coverageIgnores = ['org.slf4j.Logger.*']
coverageExcludes = ['.*package-info.*', 'net\\.gleske\\.jervis\\.exceptions\\..*']
//coberturaCheck values 80% (./gradlew coberturaCheck test)
//coverageCheckBranchRate = 80
//coverageCheckLineRate = 80
coverageCheckPackageBranchRate = 50
coverageCheckPackageLineRate = 80
coverageCheckTotalBranchRate = 50
coverageCheckTotalLineRate = 80
coverageCheckHaltOnFailure = true
}
test.finalizedBy(project.tasks.cobertura)
task printBuildScriptClasspath << {
println project.buildscript.configurations.classpath.asPath
}