forked from senx/warp10-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
338 lines (288 loc) · 10.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
//
// Copyright 2018-2020 SenX S.A.S.
//
// 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.
//
import java.text.SimpleDateFormat
buildscript {
repositories {
mavenLocal()
jcenter()
maven {
url "https://plugins.gradle.org/m2"
}
}
dependencies {
classpath "gradle.plugin.com.selesse:gradle-git-changelog:0.3.0"
}
}
plugins {
id "com.jfrog.bintray" version "1.8.4"
id "com.selesse.git.changelog" version "0.2.0"
}
allprojects {
// List of dependencies for Warpscript
ext.mc2DepsList = []
// List of unique dependency names (index)
ext.mc2DepsIndex = [] as Set
// List of dependencies required by Warpscript
ext.requiredLibsMc2 = [ 'libthrift', 'bcprov-jdk16', 'commons-io', 'commons-codec', 'commons-lang3', 'commons-math3',\
'compiler', 'core', 'curator-x-discovery', 'geoxplib', 'guava', 'hadoop-common', 'hadoop-mapreduce-client-core',\
'java-merge-sort','joda-time', 'jtransforms', 'jts', 'oss-client', 'sensision', 'slf4j-api', 'pyrolite',\
'jts2geojson', 'jackson-core', 'jackson-databind', 'jackson-annotations' ]
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.selesse.git.changelog'
group = 'io.warp10'
sourceCompatibility = 1.8
targetCompatibility = 1.8
//map key = archive base name : value a artifact version
ext {
warp10Version = [:]
commonVersion = getVersionName('')
warp10Version['warp10'] = commonVersion
warp10Version['warpscript'] = commonVersion
warp10Version['hbaseFilters'] = commonVersion
warp10Version['crypto'] = commonVersion
warp10Version['token'] = commonVersion
stagingUser = project.hasProperty('stagingUser') ? project.property('stagingUser') : System.getenv('STAGING_USER')
stagingURL = project.hasProperty('stagingURL') ? project.property('stagingURL') : System.getenv('STAGING_URL')
if (null == stagingUser || null == stagingURL) {
stagingUser = ''
stagingURL = ''
}
warpScriptPublishUser = project.hasProperty('warpScriptPublishUser') ? project.property('warpScriptPublishUser') : System.getenv('WARPSCRIPTPUBLISH_USER')
warpScriptPublishURL = project.hasProperty('warpScriptPublishURL') ? project.property('warpScriptPublishURL') : System.getenv('WARPSCRIPTPUBLISH_URL')
if (null == warpScriptPublishUser || null == warpScriptPublishURL) {
warpScriptPublishUser = stagingUser
warpScriptPublishURL = stagingURL
}
gradle.taskGraph.whenReady { graph ->
println "building warp10 version=$version"
if (graph.hasTask(uploadArchives) || graph.hasTask(bintrayUpload)) {
//if (!(version ==~ /\d+\.\d+\.\d+\-\d+\-\w+/)) {
// throw new GradleException("Cannot upload archive: version ${version} is not correct (X.X.X-X-X)")
//}
if (!isGitRepoSynced()) {
throw new GradleException("Cannot upload archive: local repo contains uncommited files (git status -u no --porcelain)")
}
}
}
}
//
// Configurations scp uploadArchives task
//
configurations {
deployerJars
}
//
// Repositories for dependency resolution For all subprojects
repositories {
jcenter()
maven {
url 'https://repository.apache.org/content/groups/public'
}
mavenCentral()
mavenLocal()
maven {
url 'https://dl.bintray.com/senx/maven'
}
maven {
url 'https://dl.bintray.com/hbs/maven'
}
}
//
// Force versions
//
configurations.all {
resolutionStrategy {
// fail eagerly on version conflict (includes transitive dependencies)
// e.g. multiple different versions of the same dependency (group and name are equal)
//failOnVersionConflict()
// force certain versions of dependencies (including transitive)
// *append new forced modules:
// This is needed to force Guava to 15.0 and not 17.0 as Renjin pulls
// HBase does not work with > 15.0
force 'com.google.guava:guava:15.0'
}
}
// GLOBAL DEPENDENCIES
dependencies {
//UPLOAD ARTIFACTS THROUGH SSH
deployerJars 'org.apache.maven.wagon:wagon-ssh-external:3.0.0'
}
// COMPILE OPTIONS
compileJava {
if (null != System.getProperty("nojvmDebug")) {
options.compilerArgs << '-g:none'
} else {
options.compilerArgs << '-g'
}
//options.debug = false;
//options.optimize = false;
//options.debugOptions.debugLevel = ''
}
//
// IDE CONFIGURATIONS
//
// IDEA DEFAULT CONFIGURATION
idea {
module {
inheritOutputDirs = true
}
}
// ECLIPSE
eclipse {
classpath {
//customizing the classes output directory:
defaultOutputDir = file('build-eclipse')
//default settings for downloading sources and Javadoc:
downloadSources = true
downloadJavadoc = false
}
}
// global tasks
//
// MUST appear before task dependencies can be defined
//
task('generateThrift').doLast({
// Delete the thrift dir if exists
if (thriftOutputDir.exists()) {
thriftOutputDir.deleteDir()
}
thriftOutputDir.mkdirs()
ext.thriftFiles = fileTree(dir: 'src/main/thrift').matching { include '**/*.thrift' }
thriftFiles.collect {
ext.file = relativePath(it)
exec {
executable = (null != System.getenv('THRIFT_HOME')) ? System.getenv('THRIFT_HOME') + '/bin/thrift' : 'thrift'
args = ['--gen', 'java:private-members', '-I', '.', '-o', thriftOutputDir, ext.file]
}
}
})
// DEPLOY ON MAVEN REPO WITH SCP
uploadArchives {
repositories {
repositories.mavenDeployer {
configuration = configurations.deployerJars
repository(url: "scpexe://${stagingURL}") {
authentication userName: stagingUser
}
}
}
}
// DEPLOY ON BINTRAY
bintray {
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
dryRun = false
publish = true
publications = ['crypto', 'token']
pkg {
repo = 'maven'
name = 'warp10'
userOrg = 'senx'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/senx/warp10-platform.git'
version {
name = getVersionName('')
released = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZZ").format(new Date())
vcsTag = getVersionName('')
}
}
}
}
// ------------------------------------------------------------------
// AUTO RELEASE MANAGEMENT
// Gets the version name from the latest Git tag
// if no commit occurs -> the name of the tag likes 0.0.1
// if commit occurs -> 0.0.1-12-aabb1122 (number of commits + version number)
// ------------------------------------------------------------------
def getVersionName(String revision) {
String newRevision = revision
if (null == System.getProperty("nogit") && !revision.endsWith('SNAPSHOT')) {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--always'
standardOutput = stdout
}
newRevision = stdout.toString().trim()
}
return newRevision
}
def updateRevision(String revision) {
//
// update Revision File
//
File versionFile = new File(rootProject.projectDir, "warp10/src/main/resources/REVISION")
versionFile.write(revision)
return revision
}
//
// Check local git repo is synced with the remote
//
def isGitRepoSynced() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'status', '-u', 'no', '--porcelain'
standardOutput = stdout
}
//
// Exclude Revision.java & gradle.properties
//
String val = stdout.toString().replaceAll(/.*\/Revision.java\n/, '')
val = val.replaceAll(/.*\/gradle.properties\n/, '')
return (0 == val.trim().size())
}
//
// Generate custom pom for WarpScript with the minimal dependencies
//
def genPomForWarpscript(Object pom) {
pom.withXml {
// compute the list of dependencies
project(":warp10").configurations.compile.resolvedConfiguration.firstLevelModuleDependencies.each {
directDep ->
addChildsToWarpscriptDeps(directDep)
}
def dependenciesNode = asNode().appendNode('dependencies')
mc2DepsList.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.getModuleGroup())
dependencyNode.appendNode('artifactId', it.getModuleName())
dependencyNode.appendNode('version', it.getModuleVersion())
}
}
}
//
// Add the root dependency and all its children (transitive dependencies) to the list
//
def addChildsToWarpscriptDeps (def pResolvedDependency) {
pResolvedDependency.children.each {
addChildsToWarpscriptDeps(it)
}
// Add the dependency and its children if it has not been seen before and if this dependency is required by Warpscript
String depName = pResolvedDependency.getModuleName()
if(!mc2DepsIndex.contains(depName) && isDepRequired(depName)) {
mc2DepsIndex << depName
mc2DepsList << pResolvedDependency
}
}
boolean isDepRequired(String currentDep ) {
return ext.requiredLibsMc2.any { currentDep.equalsIgnoreCase(it as String) }
}