forked from FoundationDB/fdb-record-layer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
271 lines (238 loc) · 8.67 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
/*
* 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()
jcenter()
}
dependencies {
classpath 'com.github.ben-manes:gradle-versions-plugin:0.13.0'
classpath 'org.jboss.tattletale:tattletale:1.2.0.Beta2'
classpath 'de.undercouch:gradle-download-task:3.1.1'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.7'
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.2'
//classpath 'gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:1.6.4'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
}
}
plugins {
id 'com.github.spotbugs' version '1.6.4'
id 'org.sonarqube' version '2.6'
}
ext {
SpotBugsTask = com.github.spotbugs.SpotBugsTask
}
defaultTasks 'build'
apply from: 'gradle/root.gradle'
apply from: 'gradle/sonar.gradle'
allprojects {
apply plugin: 'base'
apply plugin: 'java'
apply plugin: 'maven-publish'
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"
}
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")
testLogging.events = ["passed", "skipped", "failed"]
}
// 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) {
description = "Assembles a Jar archive containing the main sources."
group = JavaBasePlugin.DOCUMENTATION_GROUP
appendix = null
classifier = "sources"
from sourceSets.main.allSource
// gradle doesn't currently support autowiring for (generated) sources dirs, so we wire manually
// we do this here so that we can keep codegen plugins generic/replaceable
dependsOn {
afterEvaluate {
tasks.compileProtobuf
}
}
}
// 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
}
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()
jcenter()
}
}
apply from: file('gradle/coverage.gradle')
subprojects {
apply from: rootProject.file('gradle/testing.gradle')
sourceCompatibility = '1.8.0'
targetCompatibility = '1.8.0'
ext {
if (System.getenv('PROTO_VERSION') != null) {
protoMajorVersion = System.getenv('PROTO_VERSION')
} else {
protoMajorVersion = '2'
}
if (protoMajorVersion == "2") {
protobufVersion = protobuf2Version
} else if (protoMajorVersion == "3") {
protobufVersion = protobuf3Version
} else {
throw new GradleException("Unknown protobuf major version: ${protoMajorVersion}")
}
if (protoMajorVersion != "2") {
coreProjectName = "fdb-record-layer-core-pb${protoMajorVersion}"
shadedProjectName = "fdb-record-layer-core-pb${protoMajorVersion}-shaded"
} else {
coreProjectName = "fdb-record-layer-core"
shadedProjectName = "fdb-record-layer-core-shaded"
}
}
artifacts {
add("archives", tasks.sourcesJar)
add("archives", tasks.javadocJar)
}
afterEvaluate { project ->
if (plugins.hasPlugin('java')) {
javadoc {
// exclude generated Protobuf classes
exclude "**/*Proto.java"
// warnings are errors
options.addBooleanOption('Xwerror', true)
options.overview = "src/main/javadoc/overview.html"
}
compileJava {
//enable compilation in a separate daemon process
options.fork = true
//enable incremental compilation
options.incremental = true
}
}
}
apply from: rootProject.file('gradle/check.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 fdbEnvironment = new File("${rootProject.projectDir}/fdb-environment.properties")
if (fdbEnvironment.exists()) {
def env = [:]
fdbEnvironment.eachLine { line ->
def eq = line.indexOf('=')
if (eq > 0) env.put(line.substring(0, eq), line.substring(eq + 1))
}
if (!env.isEmpty()) {
allprojects {
tasks.withType(Test) { task ->
task.environment(env)
}
}
}
}