-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle
executable file
·306 lines (274 loc) · 8.25 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
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
plugins {
id "java"
id "scala"
id "signing"
id "maven-publish"
id "com.bmuschko.docker-remote-api" version "4.0.5"
id "com.diffplug.gradle.spotless" version "3.18.0"
id "io.codearte.nexus-staging" version "0.20.0"
id "de.marcphilipp.nexus-publish" version "0.2.0"
}
repositories {
mavenCentral()
jcenter()
}
description = "Mongoose is a high-load storage performance testing tool"
group = "com.github.emc-mongoose"
sourceCompatibility = 11
targetCompatibility = 11
version = "4.3.10"
ext {
installResourcesFileName = "install_resources.txt"
jarFileName = rootProject.name
javaHome = System.properties["java.home"]
jreOutputDir = "${rootProject.buildDir}${File.separator}jre"
rootPkg = "com.emc.mongoose"
modulesDepsFilePath = "${rootProject.buildDir}${File.separator}modules.deps"
}
configurations {
extension {
extendsFrom(compileOnly)
}
}
dependencies {
compile(
"${group}:mongoose-base:${baseVersion}",
)
extension(
"${group}:mongoose-load-step-pipeline:${loadStepPipelineVersion}",
"${group}:mongoose-load-step-weighted:${loadStepWeightedVersion}",
"${group}:mongoose-storage-driver-coop:${storageDriverCoopVersion}",
"${group}:mongoose-storage-driver-netty:${storageDriverNettyVersion}",
"${group}:mongoose-storage-driver-nio:${storageDriverNioVersion}",
"${group}:mongoose-storage-driver-http:${storageDriverHttpVersion}",
"${group}:mongoose-storage-driver-fs:${storageDriverFsVersion}",
"${group}:mongoose-storage-driver-atmos:${storageDriverAtmosVersion}",
"${group}:mongoose-storage-driver-s3:${storageDriverS3Version}",
"${group}:mongoose-storage-driver-swift:${storageDriverSwiftVersion}",
)
}
// travis deploy stage runs "./gradlew check" again which is unnecessary
check.dependsOn -= test
javadoc {
classpath += configurations.compile
}
signing {
required {
gradle.taskGraph.hasTask("uploadArchives")
}
sign configurations.archives
}
wrapper {
gradleVersion = "4.10.3"
}
task mergeInstallResourcesFile {
doLast {
def dstFile = new File("${project.buildDir}${File.separator}${installResourcesFileName}")
if(!dstFile.parentFile.exists()) {
dstFile.parentFile.mkdirs()
}
configurations.compile.copyRecursive().collect {
zipTree(it).filter {
it.toString().endsWith(installResourcesFileName)
} forEach {
it.readLines().forEach {
dstFile << it
dstFile << System.lineSeparator()
}
}
}
configurations.extension.copyRecursive().collect {
dstFile << "ext/${it.name}"
dstFile << System.lineSeparator()
}
}
}
jar.dependsOn += mergeInstallResourcesFile
jar {
baseName = rootProject.name
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
excludes = [
"**/*.css",
"**/*.html",
"META-INF/*.DSA",
"META-INF/*.LIST",
"META-INF/*.RSA",
"META-INF/*.SF",
"module-info.class",
]
manifest {
attributes(
"Automatic-Module-Name": rootPkg,
"Implementation-Title": rootProject.name,
"Implementation-Version": version,
"Main-Class": "${rootPkg}.base.Main",
"Multi-Release": "true",
)
}
from "${project.buildDir}${File.separator}${installResourcesFileName}"
from configurations.compile.copyRecursive().collect {
zipTree(it)
}
into("${File.separator}ext") {
from configurations.extension.copyRecursive().collect {
it
}
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = "javadoc"
from javadoc.destinationDir
}
// Maven Central deployment ////////////////////////////////////////////////////////////////////////////////////////////
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}
nexusStaging {
packageGroup = project.group
username = project.hasProperty("ossrhUsername") ? project.property("ossrhUsername") : null
password = project.hasProperty("ossrhPassword") ? project.property("ossrhPassword") : null
numberOfRetries = 100
delayBetweenRetriesInMillis = 10000
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = project.name
groupId = project.group
artifact jar
artifact javadocJar
artifact sourcesJar
pom {
name = project.name
description = project.description
url = "https://github.com/emc-mongoose/mongoose"
scm {
connection = "https://github.com/emc-mongoose/mongoose"
developerConnection = "https://github.com/emc-mongoose/mongoose.git"
url = "https://github.com/emc-mongoose/mongoose.git"
}
licenses {
license {
name = "The MIT License (MIT)"
url = "https://github.com/emc-mongoose/mongoose/LICENSE"
}
}
developers {
developer {
id = "akurilov"
name = "Andrey Kurilov"
email = "[email protected]"
}
}
}
}
}
repositories {
maven {
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = project.hasProperty("ossrhUsername") ? project.property("ossrhUsername") : null
password = project.hasProperty("ossrhPassword") ? project.property("ossrhPassword") : null
}
}
}
}
signing {
sign publishing.publications
}
task releaseToMavenCentral {
dependsOn += publishToNexus
dependsOn += closeAndReleaseRepository
}
// Docker tasks ////////////////////////////////////////////////////////////////////////////////////////////////////////
import com.bmuschko.gradle.docker.tasks.image.*
import com.bmuschko.gradle.docker.tasks.container.*
task dockerBuildImage(type: DockerBuildImage) {
inputDir = project.projectDir
buildArgs = [
"BASE_VERSION": baseVersion,
"LOAD_STEP_PIPELINE_VERSION": loadStepPipelineVersion,
"LOAD_STEP_WEIGHTED_VERSION": loadStepWeightedVersion,
"STORAGE_DRIVER_COOP_VERSION": storageDriverCoopVersion,
"STORAGE_DRIVER_NETTY_VERSION": storageDriverNettyVersion,
"STORAGE_DRIVER_NIO_VERSION": storageDriverNioVersion,
"STORAGE_DRIVER_FS_VERSION": storageDriverFsVersion,
"STORAGE_DRIVER_HTTP_VERSION": storageDriverHttpVersion,
"STORAGE_DRIVER_ATMOS_VERSION": storageDriverAtmosVersion,
"STORAGE_DRIVER_S3_VERSION": storageDriverS3Version,
"STORAGE_DRIVER_SWIFT_VERSION": storageDriverSwiftVersion,
]
dockerFile = project.file("ci${File.separator}docker${File.separator}Dockerfile")
imageId = "emcmongoose/mongoose".toString()
tags = [
"emcmongoose/mongoose:${version}",
"emcmongoose/mongoose:testing",
]
}
task dockerPushProductionImage(type: DockerPushImage) {
imageName = "emcmongoose/mongoose".toString()
tag = "emcmongoose/mongoose:${version}".toString()
}
task dockerPushTestingImage(type: DockerPushImage, dependsOn: dockerBuildImage) {
imageName = "emcmongoose/mongoose".toString()
tag = "emcmongoose/mongoose:testing".toString()
}
// Robot Framework /////////////////////////////////////////////////////////////////////////////////////////////////////
task dockerBuildImageRobotest(type: DockerBuildImage) {
inputDir = rootProject.projectDir
dockerFile = project.file("ci${File.separator}docker${File.separator}Dockerfile.robotest")
imageId = "emcmongoose/mongoose-robotest"
tags = [
"emcmongoose/mongoose-robotest:${version}",
]
}
task dockerCreateContainerRobotest(type: DockerCreateContainer, dependsOn: [dockerBuildImage, dockerBuildImageRobotest]) {
attachStderr = true
attachStdout = true
autoRemove = true
binds = [
"${rootProject.buildDir}": "/root/mongoose/build",
"/var/run/docker.sock": "/var/run/docker.sock",
]
envVars = [
"HOST_WORKING_DIR": rootProject.projectDir.absolutePath,
"VERSION": version,
"SERVICE_HOST": "localhost",
"SUITE": System.getenv("SUITE"),
"TEST": System.getenv("TEST"),
]
imageId = dockerBuildImageRobotest.getImageId()
network = "host"
tty = true
doLast {
println "Created the container for the ${System.env.SUITE}.${System.env.TEST} test"
}
}
task dockerStartContainerRobotest(type: DockerStartContainer, dependsOn: dockerCreateContainerRobotest) {
targetContainerId dockerCreateContainerRobotest.getContainerId()
}
task robotest(type: DockerWaitContainer, dependsOn: dockerStartContainerRobotest) {
targetContainerId dockerCreateContainerRobotest.getContainerId()
timeout = 600 // 10 min w/o output -> fail on Travis CI
doLast {
if(0 != exitCode) {
throw new GradleException("Some robotests FAILED")
} else {
println "Robotests PASSED"
}
}
}