forked from wiremock/wiremock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
323 lines (279 loc) · 10.5 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'idea'
apply plugin: 'project-report'
apply plugin: 'jdepend'
sourceCompatibility = 1.6
group = 'com.github.tomakehurst'
version = 1.36
repositories {
mavenCentral()
}
configurations {
provided
}
dependencies {
compile "org.mortbay.jetty:jetty:6.1.26"
compile "com.google.guava:guava:13.0.1"
compile "com.fasterxml.jackson.core:jackson-core:2.1.2",
"com.fasterxml.jackson.core:jackson-annotations:2.1.2",
"com.fasterxml.jackson.core:jackson-databind:2.1.2"
compile "org.apache.httpcomponents:httpclient:4.2.3"
compile "com.jayway.jsonpath:json-path:0.8.1"
compile "log4j:log4j:1.2.16"
compile "net.sf.jopt-simple:jopt-simple:4.3"
compile ("junit:junit-dep:4.10") {
exclude group: "org.hamcrest", module: "hamcrest-core"
}
testCompile "org.hamcrest:hamcrest-all:1.1"
testCompile ("org.jmock:jmock:2.5.1") {
exclude group: "junit", module: "junit-dep"
exclude group: "org.hamcrest", module: "hamcrest-core"
exclude group: "org.hamcrest", module: "hamcrest-library"
}
testCompile ("org.jmock:jmock-junit4:2.5.1") {
exclude group: "junit", module: "junit-dep"
exclude group: "org.hamcrest", module: "hamcrest-core"
exclude group: "org.hamcrest", module: "hamcrest-library"
}
testCompile "net.sf.json-lib:json-lib:2.4:jdk15"
testCompile "com.googlecode.jarjar:jarjar:1.3"
jdepend group:'jdepend', name:'jdepend', version:'2.9.1'
jdepend group:'org.apache.ant', name:'ant-jdepend', version:'1.7.1'
}
test {
// Set the timezone for testing somewhere other than my machine to increase the chances of catching timezone bugs
systemProperty 'user.timezone', 'Australia/Sydney'
}
buildscript {
repositories {
maven {
url "https://oss.sonatype.org"
}
mavenCentral()
}
dependencies {
classpath group:'org.ajoberstar', name:'gradle-plugins', version:'0.1.1'
}
}
sourceSets {
main { compileClasspath += configurations.provided }
}
eclipse {
classpath {
plusConfigurations += configurations.provided
}
}
jar {
manifest {
attributes("Main-Class": "com.github.tomakehurst.wiremock.standalone.WireMockServerRunner")
}
}
task jarAll(type: Jar, dependsOn: jar) {
inputs.files jar.archivePath
appendix = 'standalone'
def metaInfDir = "$buildDir/tmp/manifest"
def jar = project.tasks.jar
String fileName = jar.archiveName - ("." + jar.extension) + "-standalone." + jar.extension
File jarFile = new File(jar.destinationDir, fileName)
doFirst {
manifest.writeTo("${metaInfDir}/MANIFEST.MF")
project.ant {
taskdef name: "jarjar", classname: "com.tonicsystems.jarjar.JarJarTask", classpath: configurations.testCompile.asPath
jarjar(jarfile: jarFile, manifest: "${metaInfDir}/MANIFEST.MF") {
zipfileset(src: jar.archivePath)
configurations.compile.files.findAll { !it.name.contains("junit") }.each {
zipfileset(src: it)
}
rule pattern: "org.mortbay.**", result: "wiremock.org.mortbay.@1"
rule pattern: "com.google.common.**", result: "wiremock.com.google.common.@1"
rule pattern: "org.codehaus.jackson.**", result: "wiremock.org.codehaus.jackson.@1"
rule pattern: "org.apache.http.**", result: "wiremock.org.apache.http.@1"
rule pattern: "org.apache.commons.**", result: "wiremock.org.apache.commons.@1"
rule pattern: "joptsimple.**", result: "wiremock.joptsimple.@1"
}
}
Date date = new Date()
String name = jar.baseName
project.artifacts.add('archives',
[
getClassifier: { -> "standalone" },
getDate: {-> date },
getExtension: {-> "jar" },
getType: {-> "jar" },
getFile: {-> jarFile },
getName: {-> name }
] as PublishArtifact
)
}
manifest {
attributes("Main-Class": "com.github.tomakehurst.wiremock.standalone.WireMockServerRunner")
}
}
def releaseDirUrl
def user
def password
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn:javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
signing {
sign configurations.archives
}
if (!this.hasProperty('sonatypeUser')) sonatypeUser = 'default';
if (!this.hasProperty('sonatypePassword')) sonatypePassword = 'default';
uploadArchives {
repositories {
mavenDeployer {
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2') {
authentication(userName: sonatypeUser , password: sonatypePassword)
};
beforeDeployment { deployment -> signPom(deployment) };
pom.artifactId = 'wiremock'
pom.project {
packaging 'jar'
name 'WireMock'
description 'A web service test double for all occasions'
url 'https://github.com/tomakehurst/wiremock'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
connection 'https://[email protected]/tomakehurst/wiremock.git'
developerConnection 'https://[email protected]/tomakehurst/wiremock.git'
url 'https://[email protected]/tomakehurst/wiremock.git'
}
developers {
developer {
id 'tomakehurst'
name 'Tom Akehurst'
}
}
}
pom.whenConfigured { thepom ->
println thepom.dependencies.findAll({ it.artifactId.equals('junit') || it.scope.equals('test') });
thepom.dependencies.removeAll(thepom.dependencies.findAll({ it.artifactId.equals('junit') || it.scope.equals('test') }));
}
}
}
}
task release {
dependsOn clean, jarAll, uploadArchives
}
task 'set-release-dir' << {
def console = System.console()
if (console) {
println ''
def releaseDir = console.readLine('> Please enter the full path to the release dir: ')
println ''
releaseDirUrl = 'file://' + releaseDir
if (!releaseDirUrl.endsWith('/')) {
releaseDirUrl = releaseDirUrl + '/';
}
tasks.uploadArchives.repositories.mavenDeployer.repository.url = releaseDirUrl
println 'Release dir set to: ' + releaseDirUrl
} else {
logger.error "Cannot get console."
}
}
task 'release-to' {
dependsOn 'set-release-dir', clean, jarAll, uploadArchives
}
task 'bump-version' << {
def filesWithVersion = [
'build.gradle': { "version = 1.${it}" },
'docs/source/conf.py': { "version = '1.${it}'" },
'docs/source/getting-started.rst': [{ "<version>1.${it}</version>" },{ "wiremock-1.${it}-standalone.jar" }],
'sample-war/build.gradle': { "com.github.tomakehurst:wiremock:1.${it}" },
]
def gradleBuildFile = new File('build.gradle')
int currentMinorVersion
gradleBuildFile.text.find ~/version = 1.([0-9]+)/, { match, minorVersion ->
currentMinorVersion = Integer.valueOf(minorVersion)
int nextMinorVersion = currentMinorVersion + 1
filesWithVersion.each { fileName, lineWithVersionTemplates ->
def file = new File(fileName)
def lineWithVersionTemplateList = lineWithVersionTemplates instanceof List ?
lineWithVersionTemplates :
[lineWithVersionTemplates];
lineWithVersionTemplateList.each { lineWithVersionTemplate ->
def oldLine = lineWithVersionTemplate.call(currentMinorVersion)
def newLine = lineWithVersionTemplate.call(nextMinorVersion)
println "Replacing '${oldLine}' with '${newLine}' in ${fileName}"
file.text = file.text.replace(oldLine, newLine);
}
}
}
}
task 'bump-version-down' << {
def filesWithVersion = [
'build.gradle': { "version = 1.${it}" },
'docs/source/conf.py': { "version = '1.${it}'" },
'docs/source/getting-started.rst': [{ "<version>1.${it}</version>" },{ "wiremock-1.${it}-standalone.jar" }],
'sample-war/build.gradle': { "com.github.tomakehurst:wiremock:1.${it}" },
]
def gradleBuildFile = new File('build.gradle')
int currentMinorVersion
gradleBuildFile.text.find ~/version = 1.([0-9]+)/, { match, minorVersion ->
currentMinorVersion = Integer.valueOf(minorVersion)
int nextMinorVersion = currentMinorVersion - 1
filesWithVersion.each { fileName, lineWithVersionTemplates ->
def file = new File(fileName)
def lineWithVersionTemplateList = lineWithVersionTemplates instanceof List ?
lineWithVersionTemplates :
[lineWithVersionTemplates];
lineWithVersionTemplateList.each { lineWithVersionTemplate ->
def oldLine = lineWithVersionTemplate.call(currentMinorVersion)
def newLine = lineWithVersionTemplate.call(nextMinorVersion)
println "Replacing '${oldLine}' with '${newLine}' in ${fileName}"
file.text = file.text.replace(oldLine, newLine);
}
}
}
}
task 'add-copyright-headers' << {
def copyrightNotice = """/*
* Copyright (C) 2011 Thomas Akehurst
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"""
def srcDir = new File('src')
srcDir.eachFileRecurse { file ->
if (file.name.endsWith(".java") && !file.text.contains(copyrightNotice)) {
println "Adding copyright header to $file.path"
def newFileText = copyrightNotice + file.text;
file.text = newFileText;
}
}
}
task jdependReport(dependsOn: check) << {
ant.xslt(in: "$buildDir/jdepend/main.xml",
style: "jdepend.xsl",
out: "$buildDir/reports/jdepend.html"
)
}