-
Notifications
You must be signed in to change notification settings - Fork 102
/
build.gradle
298 lines (259 loc) · 10.4 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
/*
* build.gradle
*
* This source file is part of the FoundationDB open source project
*
* Copyright 2015-2018 Apple Inc. and the FoundationDB project authors
*
* 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.
*/
buildscript {
repositories {
if (Boolean.parseBoolean(mavenLocalEnabled)) {
mavenLocal()
logger.warn 'Warning: you have enabled maven local repository. This should only be used on local workstations to test undeployed library dependencies.'
}
mavenCentral()
}
dependencies {
classpath 'org.jboss.tattletale:tattletale:1.2.0.Beta2'
classpath 'com.github.jengelman.gradle.plugins:shadow:5.2.0'
}
}
plugins {
id 'com.google.protobuf' version '0.8.19'
id 'com.github.ben-manes.versions' version '0.38.0'
id 'com.github.spotbugs' version '4.6.1'
id 'com.jfrog.artifactory' version '4.29.2'
id 'de.undercouch.download' version '4.1.1'
id 'org.sonarqube' version '3.3'
}
ext {
SpotBugsTask = com.github.spotbugs.snom.SpotBugsTask
fdbEnvironment = [:]
}
defaultTasks 'build'
apply from: 'gradle/root.gradle'
apply from: 'gradle/sonar.gradle'
allprojects {
apply plugin: 'base'
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'project-reports'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'de.undercouch.download'
// Configure all source files to be read using UTF-8
project.tasks.withType(JavaCompile) {
options.encoding = "utf-8"
}
project.tasks.withType(Javadoc) {
options.encoding = "utf-8"
}
project.tasks.withType(Test) {
systemProperty "file.encoding", "utf-8"
if (project.hasProperty("apiVersion")) {
systemProperty "com.apple.foundationdb.apiVersion", project.getProperty("apiVersion")
}
}
buildDir = ".out"
ext {
distDir = ".dist"
}
// Add -SNAPSHOT to version of non-release builds
def isReleaseBuild = Boolean.parseBoolean(getProperty('releaseBuild'))
if (!isReleaseBuild) {
def versionString = project.version.toString()
if (!versionString.endsWith("-SNAPSHOT")) {
project.version = versionString + "-SNAPSHOT"
}
}
// Configure JUnit tests
tasks.withType(Test) {
reports.junitXml.destination = project.file("${->project.buildDir}/test-results")
}
// Configure JAR generation
tasks.jar.configure {
description = "Produces a Jar with the main classes in .out/."
manifest {
attributes "Built-JDK": System.getProperty("java.version"),
"Specification-Title": project.name,
"Specification-Version": "${-> project.version}",
"Specification-Vendor": "Apple Inc.",
"Implementation-Title": project.name,
"Implementation-Version": "${-> project.version}",
"Implementation-Vendor": "Apple Inc."
}
doFirst {
manifest {
attributes "Built-Date": new Date(),
"Built-By": System.getProperty("user.name")
}
}
}
// Create the sources jar
task sourcesJar(type: Jar, dependsOn: 'compileJava') {
description = "Assembles a Jar archive containing the main sources."
group = JavaBasePlugin.DOCUMENTATION_GROUP
appendix = null
classifier = "sources"
from sourceSets.main.allSource
}
// Create the Javadoc jar
task javadocJar(type: Jar) {
description = "Assembles a Jar archive containing the main Javadoc."
group = JavaBasePlugin.DOCUMENTATION_GROUP
appendix = null
classifier = "javadoc"
from tasks.javadoc
}
// Distribution
task createDistribution(type: Sync) {
// source directory depends on the subproject
into distDir
}
// Create umbrella task for all packaging operations
tasks.create("package", DefaultTask) {
description = "Produces main, sources, and Javadoc artifacts in .dist/."
dependsOn createDistribution
}
build {
dependsOn tasks.jar, tasks.package
}
signing {
if (System.getenv("GPG_KEY_ID") != null) {
def signingKeyId = System.getenv('GPG_KEY_ID')
def signingKey = System.getenv('GPG_KEY')
def signingPassword = System.getenv('GPG_PASSPHRASE')
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign configurations.archives
}
}
repositories {
if (System.getenv("ARTIFACT_VERSION") != null) {
version = "${System.getenv('ARTIFACT_VERSION')}"
} else if (System.getenv("RECORD_LAYER_BUILD_NUMBER") != null) {
version = "${version}.${System.getenv('RECORD_LAYER_BUILD_NUMBER')}"
}
if (Boolean.parseBoolean(mavenLocalEnabled)) {
mavenLocal()
logger.warn 'Warning: you have enabled maven local repository. This should only be used on local workstations to test undeployed library dependencies.'
}
mavenCentral()
}
}
subprojects {
apply from: rootProject.file('gradle/testing.gradle')
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
def publishBuild = Boolean.parseBoolean(findProperty('publishBuild') ?: 'false')
if (publishBuild) {
autoServiceVersion = autoServiceVersion
} else {
autoServiceVersion = autoServiceVersionForDevelopment
}
project.configurations.all {
resolutionStrategy.eachDependency {details ->
if (details.requested.group == 'com.google.auto.service'
&& details.requested.name == 'auto-service') {
details.useVersion autoServiceVersion
}
}
}
ext {
coreProjectName = "fdb-record-layer-core"
shadedProjectName = "fdb-record-layer-core-shaded"
}
artifacts {
add("archives", tasks.sourcesJar)
add("archives", tasks.javadocJar)
add("archives", tasks.testJar)
}
afterEvaluate { project ->
if (plugins.hasPlugin('java')) {
javadoc {
// exclude generated Protobuf classes
exclude "**/*Proto.java"
exclude "**/*ProtoV3.java"
exclude "com/apple/foundationdb/record/planprotos/*.java"
exclude "com/apple/foundationdb/record/query/plan/cascades/debug/eventprotos/*.java"
options.addBooleanOption('Xwerror', true)
// Quiet javadoc errors for missing comments, etc.
// It would be good to have more coverage, but this allows us to move forward with incomplete docs
options.addBooleanOption('Xdoclint:none', true)
options.addStringOption('source', '11')
options.with {
overview "src/main/javadoc/overview.html"
// Make our Javadocs link to external resources
// These use "linksOffline" in order to ensure that we can do offline builds as well as to tweak
// a few package lists. These should be periodically regenerated by running the
// ${packageListDir}/genpackagelists.py script. (See that script for more details.)
def packageListDir = "${project.rootDir}/build/package-lists"
linksOffline "https://apple.github.io/foundationdb/javadoc/", "${packageListDir}/fdb-java/"
linksOffline "https://developers.google.com/protocol-buffers/docs/reference/java/", "${packageListDir}/protobuf/"
// This is for dependent sub-projects so that their links to things in the Record Layer work
linksOffline "https://static.javadoc.io/org.foundationdb/fdb-extensions/${project.version}/", "${packageListDir}/fdb-extensions/"
linksOffline "https://static.javadoc.io/org.foundationdb/fdb-record-layer-core/${project.version}/", "${packageListDir}/fdb-record-layer-core/"
}
}
compileJava {
//enable compilation in a separate daemon process
options.fork = true
//enable incremental compilation
options.incremental = true
//target byte-code compatibility with Java 11 (regardless of build JDK)
options.release = 11
}
}
}
apply from: rootProject.file('gradle/check.gradle')
apply from: rootProject.file('gradle/strict.gradle')
if(System.getenv("DO_NOT_CHECK") != null) {
task check(overwrite: true, dependsOn: quickCheck) { }
}
check.dependsOn quickCheck
}
// Script for upgrading gradle. To upgrade the gradle version, set the property to the version
// you want and run the command _twice_.
wrapper {
def gradleVersion = getProperty("gradleVersion") ?: project.gradle.gradleVersion
conventionMapping.distributionUrl = {
// use gradle-all rather than gradle-bin distribution because IntelliJ's Gradle integration
// works better with the former
"https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" as String
}
}
clean.doLast {
delete ".idea_build"
allprojects.each { p ->
delete p.tasks.createDistribution.destinationDir
}
}
if (!JavaVersion.current().isJava8Compatible()) {
throw new Exception("Java 8 is required to build fdb-record-layer")
}
def fdbEnvironmentFile = new File("${rootProject.projectDir}/fdb-environment.properties")
if (fdbEnvironmentFile.exists()) {
fdbEnvironmentFile.eachLine { line ->
def eq = line.indexOf('=')
if (eq > 0) ext.fdbEnvironment.put(line.substring(0, eq), line.substring(eq + 1))
}
}
if (!ext.fdbEnvironment.isEmpty()) {
def fdbenv = ext.fdbEnvironment
allprojects {
tasks.withType(Test) { task ->
task.environment(fdbenv)
}
}
}