/
build.gradle
307 lines (259 loc) · 9.99 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
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
classpath 'com.github.jruby-gradle:jruby-gradle-jar-plugin:1.5.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
}
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'
version = '0.9.0-BETA'
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-standards', 'embulk-test'].contains(it.name) }) {
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'jacoco'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
// The version needs to be declared here, not in each build.gradle, so that "bintray" can get the value.
version = "${rootProject.version}"
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" //<< "-Xlint:deprecation"
}
tasks.withType(Test) {
systemProperties System.properties.findAll { it.key.startsWith("org.embulk") }
}
tasks.withType(Checkstyle) {
reports {
// Not to skip up-to-date checkstyles.
outputs.upToDateWhen { false }
}
}
tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
}
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
}
findbugs {
ignoreFailures = true
}
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 jar
archives testsJar
archives sourcesJar
archives javadocJar
}
publishing {
publications {
bintrayMavenRelease(MavenPublication) {
artifact jar
artifact testsJar
artifact sourcesJar
artifact javadocJar
}
}
}
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 = ['bintrayMavenRelease']
dryRun = false
publish = true
pkg {
userOrg = 'embulk'
repo = 'maven'
name = 'embulk-unstable'
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()
jcenter() // For org.embulk:guice-bootstrap:0.1.1
}
dependencies {
compile project(':embulk-core')
compile project(':embulk-standards')
}
shadowJar { // Builds a fat-JAR with recurred dependencies from the above ':embulk-core' and ':embulk-standards'.
// 'org.apache.maven' is used in:
// - embulk-core: EmbulkMigrate and EmbulkSelfUpdate (from v0.8.17)
// - embulk-core: MavenPluginSource and the related (from v0.8.26)
relocate 'org.apache.maven', 'org.embulk.third_party.org.apache.maven'
// 'org.codehaus.plexus' is used from 'org.apache.maven'.
relocate 'org.codehaus.plexus', 'org.embulk.third_party.org.codehaus.plexus'
// 'org.eclipse.aether' is used in:
// - embulk-core: MavenPluginSource and the related (from v0.8.26)
relocate 'org.eclipse.aether', 'org.embulk.third_party.org.eclipse.aether'
// 'org.apache.commons.cli' is used in:
// - embulk-core: EmbulkCommandLineParser (from v0.8.28)
relocate 'org.apache.commons.cli', 'org.embulk.third_party.org.apache.commons.cli'
// 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,
'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-unstable'
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 {
doLast {
if (!file("embulk-docs/src/release/release-${project.version}.rst").getText().contains("${project.version}")) {
throw new GradleException("Release note for ${project.version} doesn't exist")
}
if (!file("embulk-docs/src/release.rst").getText().contains("release-${project.version}")) {
throw new GradleException("embulk-docs/src/release.rst doesn't include release-${project.version}")
}
String date = new Date().format("yyyy-MM-dd")
if (!file("embulk-docs/src/release/release-${project.version}.rst").getText().contains(date)) {
throw new GradleException("embulk-docs/src/release/release-${project.version}.rst doesn't include today's release date")
}
// TODO check git-ls-files includes release-<version>.rst file
println "Ready. Run 'release' task."
}
}
task release(dependsOn: ["executableJar", "releaseCheck", "bintrayUpload"]) {
doLast {
println """
Manual operations:
git commit -am v${project.version}
git tag v${project.version}
"""
}
}
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.')
}
}