forked from mesos/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
230 lines (202 loc) · 7.7 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
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.bmuschko.gradle.docker.tasks.image.DockerPushImage
import com.bmuschko.gradle.docker.tasks.image.DockerTagImage
import com.github.zafarkhaja.semver.UnexpectedCharacterException
import com.github.zafarkhaja.semver.Version
import org.ajoberstar.grgit.Grgit
import org.ajoberstar.grgit.Tag
ext {
awaitilityVersion = "1.7.0"
commonsCollectionsVersion = "4.1"
commonsExecVersion = "1.3"
commonsIOVersion = "2.4"
commonsLangVersion = "3.4"
commonsValidatorVersion = "1.5.0"
dockerJavaVersion = "1.4.0"
elasticsearchVersion="2.2.0"
gradleDownloadTaskVersion = "2.1.0"
hamcrestVersion = "1.3"
httpClientVersion = "4.5.1"
imagePrefix = 'mesos'
jcommanderVersion = "1.48"
jodaTimeVersion = "2.9.2"
jsonVersion = "20160212"
junitVersion = "4.12"
log4jVersion = "1.2.17"
mesosVer = "0.25.0"
minimesosVersion = "0.7.1"
springBootVersion = "1.2.5.RELEASE" // Bumping SB version causes Jackson incompatabilities with Docker-Java
unirestVersion = "1.4.8"
webAngularBootstrapVersion = "1.1.2"
webAngularMomentVersion = "0.10.3"
webAngularVersion = "1.5.0"
webBootstrapVersion = "3.3.6"
webFontAwesomeVersion = "4.5.0"
webHighChartsNgVersion = "0.0.11"
webHighChartsVersion = "4.1.5"
webJsonFormatterVersion = "0.4.2"
webMomentJsVersion = "2.11.1"
webRdashUiVersion = "1.0.1"
}
allprojects {
apply plugin: 'idea'
}
idea {
project {
languageLevel = '1.8'
vcs = 'Git'
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.ajoberstar:semver-vcs-gradle-grgit:0.1.0-milestone.1"
classpath "org.ajoberstar:grgit:1.3.0"
classpath 'com.bmuschko:gradle-docker-plugin:2.4.1'
classpath "com.github.zafarkhaja:java-semver:0.9.0"
classpath 'org.springframework.boot:spring-boot:1.2.5.RELEASE'
}
}
def grgit = Grgit.open(project.file('.'))
def tags = grgit.tag.list()
def versions = []
tags.each { Tag t ->
try {
Version version = new Version.Builder(t.name).build()
versions << version
} catch (UnexpectedCharacterException e) {
// Skip, tag is invalid
}
}
Version currentVersion = new Version.Builder("0.0.0").build()
versions.each { Version v ->
if (v.greaterThan(currentVersion)) {
currentVersion = v
}
}
println "Current version: " + currentVersion
project.version = currentVersion
task incrementVersion {
if(gradle.startParameter.taskNames.contains('release')) {
if (project.hasProperty('releaseType')) {
if (releaseType == "major") {
project.version = currentVersion.incrementMajorVersion()
} else if (releaseType == "minor") {
project.version = currentVersion.incrementMinorVersion()
} else if (releaseType == "patch") {
project.version = currentVersion.incrementPatchVersion()
}
} else {
throw new GradleException('releaseType was not provided. Specify -PreleaseType={major,minor,patch}')
}
println "Next version: " + project.version
subprojects { project ->
project.version = rootProject.version.toString()
}
}
}
task release(dependsOn: [incrementVersion]) << {
if (!project.hasProperty('userName')) {
throw new GradleException('userName was not provided. Specify -PuserName=<user>')
}
grgit.tag.add(name: project.version, annotate: true, message: "RELEASE $project.version - by $userName")
grgit.push(tags: true)
}
afterEvaluate {
release.dependsOn getTasksByName('publish', true)
}
subprojects {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
apply plugin: 'sonar-runner'
apply plugin: 'java'
apply plugin: 'jacoco'
apply from: "$rootDir/gradle/quality.gradle"
apply plugin: 'com.bmuschko.docker-remote-api'
task showDeps(type: DependencyReportTask) {}
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
version = rootProject.version.toString()
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
group = "org.apache.mesos"
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://jitpack.io"
}
}
dependencies {
compile "org.apache.mesos:mesos:${mesosVer}"
compile 'com.google.code.gson:gson:2.3' // marshalling between the scheduler and executor
compile 'com.google.code.findbugs:annotations:3.0.0'
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-all:1.9.5"
}
sonarRunner {
sonarProperties {
property "sonar.sourceEncoding", "UTF-8"
property "sonar.dynamicAnalysis", "reuseReports"
property "sonar.jacoco.reportPath", "${buildDir}/jacoco/test.exec"
}
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
}
}
afterEvaluate { project ->
if (new File(project.projectDir, 'Dockerfile').exists()) {
if (!project.hasProperty('imageName')) {
throw new GradleException('Root directory of ' + project.name
+ ' contains Dockerfile, but it does not define project.ext.imageName value')
}
docker.url = 'unix:///var/run/docker.sock'
if(!System.properties['os.name'].equals('Mac OS X')) {
docker.certPath = null
}
if (System.env.DOCKER_HOST) {
docker.url = "$System.env.DOCKER_HOST".replace("tcp","https")
if (System.env.DOCKER_CERT_PATH) {
docker.certPath = new File(System.env.DOCKER_CERT_PATH)
}
}
task buildDockerImage(type: DockerBuildImage, dependsOn: [taskCopyFilesForDocker], description: 'build Docker image') {
inputDir = file(project.projectDir)
tag = project.imageName
}
if (!project.imageName.contains("base")) { // We don't want to push anything common to the other projects.
['snapshot', 'latest', 'version'].each { aTag ->
String uppercasedName = aTag.capitalize()
task "tagDockerImageWith$uppercasedName"(type: DockerTagImage, description: 'tag Docker image') {
imageId = project.imageName
tag = ('version'.equals(aTag)) ? project.version : aTag
repository = project.imageName
force = true
}
task "publishDockerImageWith$uppercasedName"(type: DockerPushImage, dependsOn: ["tagDockerImageWith$uppercasedName"],
description: 'publish Docker image') {
imageName = project.imageName
tag = ('version'.equals(aTag)) ? project.version : aTag
doFirst {
['dockerHubUsername', 'dockerHubPassword', 'dockerHubEmail'].each {
assert project.hasProperty(it): 'Undefined "' + it + '" property'
}
docker {
registryCredentials {
username = project.property('dockerHubUsername')
password = project.property('dockerHubPassword')
email = project.property('dockerHubEmail')
}
}
}
}
}
}
}
}
}