forked from cinchapi/concourse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
300 lines (272 loc) · 11.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
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
/*
* Copyright (c) 2013-2023 Cinchapi Inc.
*
* 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.
*/
// The project version is controlled externally by the "version.sh" script.
def getVersion = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'bash', 'version.sh'
standardOutput = stdout
}
return stdout.toString().trim()
}
def validateVersion = { version ->
def matcher = version =~/^(\d+\.)?(\d+\.)?(\d+\.)?(\d+)(-SNAPSHOT){0,1}$/
return matcher.matches() || System.getenv('FORCE_PUBLISH')
}
ext.globalVersion = getVersion()
ext.isWindows = System.getProperty("os.name").toLowerCase().contains("windows")
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'net.nisgits.gradle:gradle-executable-jar-plugin:1.7.0'
classpath "com.diffplug.spotless:spotless-plugin-gradle:5.1.2"
}
}
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'maven-publish'
repositories {
mavenCentral()
mavenLocal()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
url "https://packages.cinchapi.com/public/open-source/maven/"
}
maven {
url "https://packages.cinchapi.com/public/open-source-snapshots/maven/"
}
maven {
url "https://packages.cinchapi.com/public/platform/maven/"
}
maven {
url "https://packages.cinchapi.com/public/platform-snapshots/maven/"
}
maven {
url "https://packages.cinchapi.com/public/enterprise/maven/"
credentials {
username = System.getenv('CLOUDSMITH_API_USER')
password = System.getenv('CLOUDSMITH_API_KEY')
}
}
maven {
url "https://packages.cinchapi.com/public/enterprise-snapshots/maven/"
credentials {
username = System.getenv('CLOUDSMITH_API_USER')
password = System.getenv('CLOUDSMITH_API_KEY')
}
}
jcenter()
}
configurations {
all*.exclude group: 'org.cinchapi', module: 'concourse'
all*.exclude group: 'com.google.code.findbugs', module: 'annotations'
}
// Ensure that these transitive dependencies are excluded so we don't get version clashes
def exclusions = [[group : 'com.google.guava', module: 'guava'], [group : 'com.cinchapi', module: 'concourse-driver-java']]
exclusions.each { exclusion ->
configurations.compile.dependencies.all {
if (name != exclusion.module || group != exclusion.group) {
exclude group: exclusion.group, module: exclusion.module
}
}
}
dependencies {
compile 'com.google.guava:guava:25.1-jre'
compile 'org.mockito:mockito-all:1.9.5'
compile 'commons-codec:commons-codec:1.8'
compile 'com.google.code.findbugs:jsr305:2.0.1'
compile 'org.slf4j:slf4j-api:1.7.5'
compile 'ch.qos.logback:logback-classic:1.2.11'
compile 'joda-time:joda-time:2.2'
compile 'org.apache.thrift:libthrift:0.12.0'
compile 'commons-configuration:commons-configuration:1.9'
compile group: 'com.cinchapi', name: 'accent4j', version: '1.13.1', changing:true
compile 'com.cinchapi:lib-config:1.5.1'
compile group: 'com.cinchapi', name: 'lib-cli', version: '1.1.1', changing:true
testCompile 'junit:junit:4.11'
}
test {
testLogging {
events 'standard_error'
}
}
group = 'com.cinchapi'
version = globalVersion
// Versions for some shared (but non-global) dependencies
ext.bucketVersion = '1.6.2'
// Drop the build component from version number and use that for
// publishing
ext.mavenVersion = version.split('\\.')
ext.mavenVersion[3] = ext.mavenVersion[3].replaceAll("[0-9]+-", "-")
ext.mavenVersion[3] = ext.mavenVersion[3].replaceAll("[0-9]+", "").trim()
ext.mavenVersion = ext.mavenVersion.join(".").replace(".-", "-").replaceAll('\\.$', "")
jar {
manifest {
attributes("Specificiation-Title": "Concourse", "Specificiation-Version": version, "Implementation-Version": version)
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
javadoc {
exclude "**/thrift/**"
options.windowTitle 'Concourse Java API'
options.noQualifiers 'all'
options.links 'https://docs.oracle.com/javase/8/docs/api/'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
test {
exclude '**/*Suite.class'
}
spotless {
java {
licenseHeaderFile rootProject.file('spotless.java.license')
importOrderFile rootProject.file('spotless.java.importerorder')
removeUnusedImports()
eclipse().configFile rootProject.file('spotless.java.eclipseformat.xml')
targetExclude 'src/main/java/com/cinchapi/concourse/thrift/ConcourseService.java'
}
}
// THESE PROPERTIES SHOULD BE OVERRIDDEN BY EACH SUBPROJECT!
ext.uploadEnabled = false // Controls if artifacts are uploaded to Maven
ext.title = "Concourse" // The project's vanity title
ext.description = "Default" // A short description about the project
afterEvaluate { project ->
if (project.ext.uploadEnabled && validateVersion(project.version)) { // Configure subprojects that should be uploaded // to Maven
def mavenTitle = project.ext.title
def mavenDescription = project.ext.description
def mavenVersion = ext.mavenVersion
publishing {
repositories {
maven {
name = 'cloudsmith'
def releasesRepoUrl = "https://api-g.cloudsmith.io/maven/cinchapi/open-source/"
def snapshotsRepoUrl = "https://api-g.cloudsmith.io/maven/cinchapi/open-source-snapshots/"
url = mavenVersion.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = System.getenv('CLOUDSMITH_API_USER')
password = System.getenv('CLOUDSMITH_API_KEY')
}
}
}
publications {
maven(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
groupId group
artifactId project.name
version mavenVersion
// Edit the generated POM to set the dependency version
// for any Cinchapi projects to be the version that is
// configured in the project's POM (X.Y.Z[-SNAPSHOT])
// instead of the fully qualified version used when
// labeling the jar distributed with the server
// (X.Y.Z.B[-SNAPSHOT]).
pom.withXml {
asNode().dependencies.first().each {
def groupId = it.get("groupId").first().value().first()
def artifactId = it.get("artifactId").first().value().first()
if(groupId.equals("com.cinchapi") && artifactId.startsWith("concourse") && !artifactId.equals("concourse-plugin-bundle-generator")) {
it.get("version").first().value = mavenVersion
}
}
}
}
}
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment {
MavenDeployment deployment -> signing.signPom(deployment)
}
pom.version = mavenVersion
pom.project {
name mavenTitle
description mavenDescription
url 'https://github.com/cinchapi/concourse'
packaging 'jar'
scm {
url 'git@github.com:cinchapi/concourse.git'
connection 'git@github.com:cinchapi/concourse.git'
developerConnection 'git@github.com:cinchapi/concourse.git'
}
licenses {
license {
name 'The Apache License'
url 'http://opensource.org/licenses/Apache-2.0'
distribution 'repo'
}
}
developers {
developer {
id 'jnelson'
name 'Jeff Nelson'
}
}
}
// Edit the generated POM to set the dependency version
// for any Cinchapi projects to be the version that is
// configured in the project's POM (X.Y.Z[-SNAPSHOT])
// instead of the fully qualified version used when
// labeling the jar distributed with the server
// (X.Y.Z.B[-SNAPSHOT]).
pom.withXml {
asNode().dependencies.first().each {
def groupId = it.get("groupId").first().value().first()
def artifactId = it.get("artifactId").first().value().first()
if(groupId.equals("com.cinchapi") && artifactId.startsWith("concourse") && !artifactId.equals("concourse-plugin-bundle-generator")) {
it.get("version").first().value = pom.version
}
}
}
def mavenUrl = pom.version.matches('^[0-9]+\\.[0-9]+\\.[0-9]+(-rc[0-9]+){0,1}$') ? 'https://oss.sonatype.org/service/local/staging/deploy/maven2' : 'https://oss.sonatype.org/content/repositories/snapshots'
repository(url: mavenUrl) {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
}
}
}
}
}
}