forked from embulk/embulk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
369 lines (317 loc) · 12.6 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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'org.ajoberstar.grgit:grgit-gradle:3.0.0'
classpath "org.owasp:dependency-check-gradle:5.2.1"
}
}
def getRevision = { ->
def stdout = new ByteArrayOutputStream()
exec {
workingDir "${rootDir}"
commandLine "git", "rev-parse", "HEAD"
standardOutput = stdout
}
return stdout.toString().trim()
}
def revision = getRevision()
allprojects { // Applies all projects including the root project as well.
apply plugin: 'java'
group = 'org.embulk'
sourceCompatibility = 1.8
targetCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
test {
maxHeapSize = '1536m'
forkEvery = 1 // test processes are forked by each test class (default is 0)
}
}
apply plugin: 'maven-publish'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'org.ajoberstar.grgit'
apply plugin: "org.owasp.dependencycheck"
version = '0.9.23-SNAPSHOT'
description = 'Embulk is an open-source, plugin-based bulk data loader to scale and simplify data management across heterogeneous data stores. It can collect and ship any kinds of data in high throughput with transaction control.'
ext {
jrubyVersion = '9.1.15.0'
summary = 'Embulk, a plugin-based parallel bulk data loader'
}
configure(subprojects.findAll { ['embulk-core', 'embulk-deps-buffer', 'embulk-deps-cli', 'embulk-deps-guess', 'embulk-deps-config', 'embulk-deps-maven', 'embulk-standards', 'embulk-test'].contains(it.name) }) {
apply plugin: 'checkstyle'
apply plugin: 'jacoco'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
// TODO: Enable SpotBugs instead of FindBugs which was used in Embulk until v0.9.17.
// The version needs to be declared here, not in each build.gradle, so that "bintray" can get the value.
version = "${rootProject.version}"
project.ext.setProperty("revision", revision)
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
tasks.withType(Test) {
systemProperties System.properties.findAll { it.key.startsWith("org.embulk") }
testLogging {
outputs.upToDateWhen { false }
showStandardStreams = true
}
}
tasks.withType(Checkstyle) {
reports {
// Not to skip up-to-date checkstyles.
outputs.upToDateWhen { false }
}
}
checkstyle {
toolVersion '8.7'
configFile = file("${rootProject.projectDir}/config/checkstyle/checkstyle.xml")
configProperties = [
'checkstyle.config.path': file("${projectDir}/config/checkstyle")
]
ignoreFailures = false
maxWarnings = 0 // https://github.com/gradle/gradle/issues/881
}
javadoc {
options {
locale = 'en_US'
encoding = 'UTF-8'
}
}
jar {
manifest {
attributes 'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor-Id': project.group,
'Specification-Title': project.name,
'Specification-Version': project.version
}
}
task testsJar(type: Jar, dependsOn: classes) {
classifier = 'tests'
from sourceSets.test.output
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives testsJar
archives sourcesJar
archives javadocJar
}
publishing {
publications {
maven(MavenPublication) {
if (project.version.endsWith("-SNAPSHOT")) {
version = "${project.version}-${revision}"
}
from components.java
artifact testsJar
artifact sourcesJar
artifact javadocJar
}
}
// publishMavenPublicationToGithubRepository
repositories {
maven {
name = "github"
url "https://maven.pkg.github.com/embulk/embulk"
credentials {
username = project.hasProperty("github_package_user") ? github_package_user : ""
password = project.hasProperty("github_package_token") ? github_package_token : ""
}
}
}
}
bintray { // Defines "bintrayUpload" properties for Java subprojects.
// NOTE: Define Gradle properties "bintray_user" and "bintray_api_key" to upload the releases to Bintray.
// ~/.gradle/gradle.properties would help defining.
user = project.hasProperty('bintray_user') ? bintray_user : ''
key = project.hasProperty('bintray_api_key') ? bintray_api_key : ''
publications = ["maven"]
dryRun = false
publish = true
pkg {
userOrg = 'embulk'
repo = 'maven'
name = 'embulk'
desc = 'Embulk, a plugin-based parallel bulk data loader'
websiteUrl = 'https://github.com/embulk/embulk'
issueTrackerUrl = 'https://github.com/embulk/embulk/issues'
vcsUrl = 'https://github.com/embulk/embulk.git'
licenses = ['Apache-2.0']
labels = ['embulk', 'ruby', 'java']
publicDownloadNumbers = true
version {
name = project.version
}
}
}
}
repositories {
mavenCentral()
}
configurations {
embed
}
dependencies {
compile project(':embulk-core')
compile project(':embulk-standards')
// Logback and jansi are included only in the executable package. (jansi for logback colors to work on Windows.)
compile 'ch.qos.logback:logback-classic:1.1.3'
compile 'org.fusesource.jansi:jansi:1.11'
embed project(':embulk-deps-buffer')
embed project(':embulk-deps-config')
embed project(':embulk-deps-guess')
embed(project(':embulk-deps-maven')) {
exclude group: 'org.apache.commons', module: 'commons-lang3' // Included in embulk-core.
exclude group: 'com.google.guava', module: 'guava' // Included in embulk-core.
}
embed project(':embulk-deps-cli')
}
def listEmbedDependencies = { rootModuleName, prefix ->
def list = []
configurations.embed.resolvedConfiguration.firstLevelModuleDependencies.each { firstLevelDependency ->
if (firstLevelDependency.moduleName == rootModuleName) {
firstLevelDependency.allModuleArtifacts.each { requiredArtifact ->
list.add(prefix + requiredArtifact.file.name)
}
}
}
if (list.isEmpty()) {
throw new GradleException('Failed to collect libraries to embed: no dependencies found for: "' + rootModuleName + '"')
}
return String.join(' ', list)
}
// Workaround: "*.jar" resources in the shadowed JAR are unfortunately unzipped by the Gradle Shadow plugin.
// @see https://github.com/johnrengelman/shadow/issues/111
task embeddedJarsJar(type: Jar) {
doFirst {
delete file("$buildDir/embeddedJars")
}
baseName = 'embulk-embedded'
classifier = null
destinationDir file("$buildDir/embeddedJars")
exclude 'META-INF/**'
into('/lib') {
from configurations.embed
}
}
shadowJar { // Builds a fat-JAR with recurred dependencies from the above ':embulk-core' and ':embulk-standards'.
dependsOn embeddedJarsJar
from embeddedJarsJar
// NOTE: This 'Implementation-Version' in the manifest is referred to provide the Embulk version at runtime.
// See also: embulk-core/src/main/java/org/embulk/EmbulkVersion.java
manifest {
attributes 'Implementation-Title': 'embulk',
'Implementation-Version': project.version,
'Implementation-Vendor-Id': project.group,
'Specification-Title': 'embulk',
'Specification-Version': project.version,
'Embulk-Resource-Class-Path-Buffer': listEmbedDependencies('embulk-deps-buffer', '/lib/'),
'Embulk-Resource-Class-Path-Config': listEmbedDependencies('embulk-deps-config', '/lib/'),
'Embulk-Resource-Class-Path-Guess': listEmbedDependencies('embulk-deps-guess', '/lib/'),
'Embulk-Resource-Class-Path-Maven': listEmbedDependencies('embulk-deps-maven', '/lib/'),
'Embulk-Resource-Class-Path-Cli': listEmbedDependencies('embulk-deps-cli', '/lib/'),
'Main-Class': 'org.embulk.cli.Main'
}
append("${rootProject.projectDir}/COPYING")
}
task executableJar(dependsOn: 'shadowJar') { // Builds an executable fat-JAR from "shadowJar".
ext.destinationDir = file("${buildDir}/executable")
doFirst {
destinationDir.mkdirs()
}
ext.destination = file("${destinationDir}/embulk-${project.version}.jar")
doLast {
destination.write("")
destination.append("\n: <<END_OF_EMBULK_SELFRUN_BATCH_PART\r\n")
destination.append(file("embulk-core/src/main/bat/selfrun.bat").readBytes())
destination.append("\r\nEND_OF_EMBULK_SELFRUN_BATCH_PART\r\n\n")
destination.append(file("embulk-core/src/main/sh/selfrun.sh").readBytes())
destination.append(file("${buildDir}/libs/embulk-${project.version}-all.jar").readBytes())
destination.setExecutable(true)
}
}
task cli(type: Copy, dependsOn: 'executableJar') {
doFirst {
file('pkg').mkdirs()
}
from executableJar.destination
into file('pkg')
}
bintray { // Defines "bintrayUpload" properties for the root project's executable fat-JAR.
// NOTE: Define Gradle properties "bintray_user" and "bintray_api_key" to upload the releases to Bintray.
// ~/.gradle/gradle.properties would help defining.
user = project.hasProperty('bintray_user') ? bintray_user : ''
key = project.hasProperty('bintray_api_key') ? bintray_api_key : ''
// No "publications". The executable embulk-${version}.jar (built by "executableJar") is uploaded by "filesSpec".
// The executable is uploaded into the root directory of the version at Bintray.
filesSpec {
from executableJar.destination
into "."
}
dryRun = false
publish = true
pkg {
userOrg = 'embulk'
repo = 'maven'
name = 'embulk'
desc = "${project.summary}"
websiteUrl = 'https://github.com/embulk/embulk'
issueTrackerUrl = 'https://github.com/embulk/embulk/issues'
vcsUrl = 'https://github.com/embulk/embulk.git'
licenses = ['Apache-2.0']
labels = ['embulk', 'ruby', 'java']
publicDownloadNumbers = true
version {
name = project.version
}
}
}
bintrayUpload.dependsOn(['executableJar'])
task releaseCheck {
doFirst {
if (rootProject.version.endsWith("-SNAPSHOT")) {
throw new GradleException("Not for release. The version in build.gradle is SNAPSHOT: ${rootProject.version}")
}
def grgit = org.ajoberstar.grgit.Grgit.open(dir: "${rootProject.projectDir}")
if (!grgit.status().clean) {
throw new GradleException("Not for release. The working tree is dirty.")
}
def described = grgit.describe(commit: "HEAD").toString().trim()
if (described != "v${rootProject.version}") {
throw new GradleException("Not for release. git-describe returned a name different from the version in build.gradle: ${described} v.s. v${rootProject.version}")
}
if (described.contains("-")) {
// HEAD may not be tagged with annotation properly.
throw new GradleException("Not for release. git-describe returned a name with a hyphen: ${described}")
}
// TODO: Revisit if we would check the format of tag annotation.
}
doLast {
println "Ready. Run 'release' task."
}
}
task release(dependsOn: ["executableJar", "releaseCheck", "bintrayUpload"]) {
}
bintrayUpload.mustRunAfter('releaseCheck')
task setVersion {
doFirst {
throw new GradleException('Gradle task "setVersion" no longer exists. Edit "version" in build.gradle.')
}
}
task updateJRuby {
doFirst {
throw new GradleException('Gradle task "updateJRuby" no longer exists. Edit "jrubyVersion" in build.gradle.')
}
}