-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
212 lines (184 loc) · 6.23 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
//==================================================
// ctzen-common build file
//==================================================
group = 'com.ctzen'
version = '1.0'
defaultTasks 'clean', 'build'
apply plugin: 'groovy'
//==================================================
// dependencies
//==================================================
repositories {
mavenCentral()
}
dependencies {
// groovy
compile 'org.codehaus.groovy:groovy-all:2.3.6' // version matches eclipse plug-in
// must haves
compile 'org.apache.commons:commons-lang3:3.3.2'
// logging
compile 'org.slf4j:slf4j-api:1.7.7'
runtime 'ch.qos.logback:logback-classic:1.1.2'
runtime 'org.slf4j:jcl-over-slf4j:1.7.7' // bridge commons-logging to slf4j
runtime 'org.slf4j:log4j-over-slf4j:1.7.7' // bridge log4j to slf4j
// testing
testCompile 'org.slf4j:jcl-over-slf4j:1.7.7' // need this to compile groovy tests
testCompile 'org.testng:testng:6.8.8'
testRuntime 'org.uncommons:reportng:1.1.4' // nicer testng reports
testRuntime 'com.google.inject:guice:2.0' // required by reportng (no major version due to bad meta on repo)
}
configurations {
all*.exclude group: 'commons-logging' // exclude to use slf4j
all*.exclude group: 'log4j' // exclude to use slf4j
}
//==================================================
// java / groovy
//==================================================
ext {
// CANNOT be full path or eclipse plugin may misbehave!
srcDir = 'src' // main sources and resources
classesDir = 'build/classes' // main classes
testSrcDir = 'src-test' // test sources and resources
testClassesDir = 'build/classes-test' // test classes
assetsDir = 'assets' // e.g. reportng css
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.deprecation = true
options.compilerArgs << '-Xlint:unchecked'
}
tasks.withType(GroovyCompile) {
options.encoding = 'UTF-8'
options.deprecation = true
options.compilerArgs << '-Xlint:unchecked'
}
sourceSets {
main {
java {
srcDirs = []
}
groovy {
srcDirs = ["${srcDir}"]
}
resources {
srcDirs = ["${srcDir}"] // note same as main source
}
output.classesDir = "${classesDir}"
output.resourcesDir = "${classesDir}" // note same as main classes
}
test {
java {
srcDirs = []
}
groovy {
srcDirs = ["${testSrcDir}"]
}
resources {
srcDirs = ["${testSrcDir}"] // note same as test source
}
output.classesDir = "${testClassesDir}"
output.resourcesDir = "${testClassesDir}" // note same as test classes
}
}
// workaround dup entries in jar until GRADLE-2213 is fixed
jar.doFirst {
sourceSets.main.output.resourcesDir = "/does/not/exist"
}
jar.doLast {
sourceSets.main.output.resourcesDir = sourceSets.main.output.classesDir
}
//==================================================
// unit test
//==================================================
apply plugin: 'jacoco'
test {
useTestNG() {
parallel 'tests'
threadCount 5
}
systemProperty 'org.uncommons.reportng.stylesheet', "${assetsDir}/reportng-custom.css"
options {
listeners << 'org.uncommons.reportng.HTMLReporter' // use reportng
listeners << 'org.uncommons.reportng.JUnitXMLReporter' // also produce junit xml reports for
// downstream build step such as
// jenkins' unit test report
}
jacoco {
append = false
destinationFile = file("${reporting.baseDir}/jacoco/jacoco.exec")
}
doLast {
jacocoTestReport.execute()
}
}
jacocoTestReport {
group = 'Reporting'
description = 'Generate Jacoco unit tests coverage report.'
dependsOn test
reports {
xml.enabled = false
csv.enabled false
html.enabled true
html.destination "${reporting.baseDir}/jacoco/html"
}
}
//==================================================
// eclipse integration
//==================================================
apply plugin: 'eclipse'
eclipse {
classpath {
downloadSources = true
// setup separate output classes folders.
defaultOutputDir = file("${classesDir}")
file {
// Classpath entry for Eclipse which changes the order of classpathentries
// otherwise no sources for 3rd party jars are shown
withXml { xml ->
def node = xml.asNode()
def j2eeNode = node.find { it.@path == 'org.eclipse.jst.j2ee.internal.web.container' }
if (j2eeNode) {
node.remove(j2eeNode)
node.appendNode( 'classpathentry', [ kind: 'con', path: 'org.eclipse.jst.j2ee.internal.web.container', exported: 'true'])
}
}
// switch test classes output folder
whenMerged { cp ->
cp.entries.findAll {
it.kind == 'src' && it.path == "${testSrcDir}"
}*.output = "${testClassesDir}"
}
}
}
}
// always clean when generating eclipse project files
// because the generated files without cleaning could be bad
tasks.eclipse.dependsOn cleanEclipse
//==================================================
// publish
//==================================================
apply plugin: 'maven-publish'
task sourceJar(type: Jar) {
from sourceSets.main.allSource
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar {
classifier "sources"
}
}
}
}
task publishLocal {
group = 'Publishing'
description = 'Alias for publishToMavenLocal'
dependsOn publishToMavenLocal
}
//==================================================
// gradle wrapper
//==================================================
task wrapper(type: Wrapper) {
gradleVersion = '2.1'
}