-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.gradle
248 lines (203 loc) · 6.81 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
buildscript {
repositories {
mavenCentral()
jcenter()
}
}
plugins {
id 'com.github.ben-manes.versions' version '0.11.3'
}
apply plugin: 'java'
apply plugin: 'maven'
ext {
junitVersion = '4.11'
artifactsDir = "$projectDir/artifacts"
artifactGroupId = 'au.com.ausregistry'
gradleWrapperVersion = '2.7'
pagesProjectDir = "$projectDir/../ari-toolkit-gitpages"
checkstyleConfDirPath = "$projectDir/checkstyle/"
commonsCodecVersion = '1.10'
simpleFrameworkVersion = '4.1.21'
httpClientVersion = '4.5.1'
powerMockVersion = '1.6.3'
hamcrestVersion = '1.3'
ariMockHttpServerVersion = '1.0.2'
}
version = toolkitVersion
repositories {
mavenCentral()
flatDir name:'ExternalJars',dirs:'lib'
}
sourceSets {
test {
java.srcDir('src/test/unit/java')
resources.srcDir('src/test/unit/resources')
}
componentTest {
java.srcDir('src/test/component/java')
resources.srcDir('src/test/component/resources')
}
integrationTest {
java.srcDir('src/test/integration/java')
resources.srcDir('src/test/integration/resources')
}
}
dependencies {
compile("commons-codec:commons-codec:$commonsCodecVersion") {
exclude group: 'junit', module: 'junit'
}
compile "org.apache.httpcomponents:httpclient:$httpClientVersion"
testCompile "org.hamcrest:hamcrest-all:$hamcrestVersion"
testCompile "org.simpleframework:simple:$simpleFrameworkVersion"
testCompile("org.powermock:powermock-api-mockito:$powerMockVersion") {
exclude module: 'junit'
}
testCompile("org.powermock:powermock-module-junit4:$powerMockVersion") {
exclude module: 'junit'
}
testCompile ("junit:junit-dep:$junitVersion") {
exclude group: 'org.hamcrest', module: 'hamcrest-core' // exclude hamcrest-core 1.3
}
integrationTestCompile sourceSets.main.output
integrationTestCompile configurations.testCompile
componentTestCompile sourceSets.main.output
componentTestCompile configurations.testCompile
componentTestCompile "ari-mock-http-server:ari-mock-http-server:$ariMockHttpServerVersion"
}
tasks.withType(JavaCompile) {
sourceCompatibility = '1.6'
targetCompatibility = '1.6'
options.encoding = "UTF-8"
options.compilerArgs << "-Xlint:-options"
}
tasks.withType(Test) {
jvmArgs '-Dfile.encoding=UTF8'
}
task cleanArtifacts(type: Delete) {
delete artifactsDir
}
test {
outputs.upToDateWhen { false }
exclude '**/PerfTest.class'
exclude '**/SessionTest.class'
exclude '**/SessionManagerTest.class'
}
javadoc {
destinationDir = file("$artifactsDir/javadoc")
}
clean.dependsOn cleanArtifacts
test.dependsOn jar
task integrationTest(type: Test) {
testClassesDir = sourceSets.integrationTest.output.classesDir
reports.junitXml.destination = "build/test-results/integration"
classpath += sourceSets.integrationTest.runtimeClasspath
}
task componentTest(type: Test) {
onlyIf { // on Travis if runtime is JDK6 it would complain about major.minor version of MockHttpServer
isJava7Compatible()
}
testClassesDir = sourceSets.componentTest.output.classesDir
reports.junitXml.destination = "build/test-results/component"
classpath += sourceSets.componentTest.runtimeClasspath
classpath += sourceSets.componentTest.runtimeClasspath
}
//Run this task to download the gradle wrapper corresponding to the gradleWrapperVersion number
task wrapper(type: Wrapper) {
gradleVersion = "$gradleWrapperVersion"
}
jar {
manifest {
attributes('Specification-Title': 'ari java toolkit',
'Specification-Version': "${version}",
'Implementation-Version': "${version}",
"Implementation-Timestamp": new Date())
}
}
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn:javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task checkVersionNumbersInReadme << {
def readme = file("readme.md")
def looksLikeVersionNumber = ~/\d+\.\d+\.\d+/
def textNeedFixedVersion = 'Since version 3.7.6 the toolkit no longer support Java SE 6.'
def versionNumbersInReadmeFile = readme.readLines()
.findAll { line ->
!line.startsWith(textNeedFixedVersion)
}
.collectMany { line ->
looksLikeVersionNumber.matcher(line).collect { match ->
(toolkitVersion == match) ? null : match
}.findResults{ x -> x }
}
def decommissionJava6LineWithFixedVersion = readme.readLines().find {line ->
line.startsWith(textNeedFixedVersion)
}
assert versionNumbersInReadmeFile.isEmpty()
assert decommissionJava6LineWithFixedVersion != null
}
artifacts {
archives sourcesJar
archives javadocJar
}
uploadArchives {
uploadDescriptor = false
repositories {
flatDir {
dirs artifactsDir
}
if (System.properties.keySet().containsAll('repoUrl', 'repoUsername', 'repoPassword')) {
mavenDeployer {
repository(url: System.properties['repoUrl']) {
authentication(userName: System.properties['repoUsername'], password: System.properties['repoPassword'])
}
pom.groupId = artifactGroupId
pom.artifactId = rootProject.name
pom.version = toolkitVersion
}
} else {
mavenDeployer {
repository(url: "file://$pagesProjectDir/repo")
pom.groupId = artifactGroupId
pom.artifactId = rootProject.name
pom.version = toolkitVersion
}
}
}
}
uploadArchives << {
if (!System.properties.keySet().containsAll('repoUrl', 'repoUsername', 'repoPassword')) {
copy {
from(javadoc.destinationDir)
into "$pagesProjectDir/javadoc/ari-toolkit"
}
}
}
uploadArchives.dependsOn checkVersionNumbersInReadme, javadoc
integrationTest.shouldRunAfter test
componentTest.shouldRunAfter integrationTest
apply plugin: 'checkstyle'
checkstyle {
configFile = file(checkstyleConfDirPath + 'checkstyle.xml')
configProperties = [checkstyleConfigDir: checkstyleConfDirPath]
toolVersion = "6.19"
}
tasks.withType(Checkstyle) {
onlyIf { // on Travis if runtime is JDK6 it would complain about major.minor version of Checkstyle tool
isJava7Compatible()
}
classpath = project.sourceSets.main.output
classpath += configurations.compile
classpath += configurations.testCompile
classpath += configurations.integrationTestCompile
}
check.dependsOn test
check.dependsOn integrationTest
check.dependsOn componentTest
boolean isJava7Compatible() {
JavaVersion.current().java7Compatible
}