-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
306 lines (278 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
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Contributors to the ODPi Egeria project.
*
* To build against the hms stable release v3.1.3:
* ./gradlew build
*
* To build version to support IBM Data Engine
* See https://cloud.ibm.com/docs/sql-query?topic=sql-query-hive_metastore#apache-hive-metastore-3.1.2-compatible-client
* ./gradlew build -Pibmhms
*
* To build version to support to work with hms v4
* ./gradlew build -Phmsv4
*/
plugins {
id 'java-library'
id "com.github.johnrengelman.shadow" version "8.1.0"
id 'idea'
id 'maven-publish'
// Checks for unnecessary & problematic dependencies
id 'com.autonomousapps.dependency-analysis' version "1.31.0"
// helps resolve log implementation clashes
id 'dev.jacomet.logging-capabilities' version "0.11.1"
// This plugin helps resolve jakarta/javax clashes
id 'org.gradlex.java-ecosystem-capabilities' version "1.3.1"
}
// Only do signing when running under github actions
if (System.getenv("CI")) {
apply plugin: 'signing'
}
repositories {
mavenCentral()
maven { url("https://oss.sonatype.org/content/repositories/snapshots") }
// Needed for old jackson implementation fixed libraries (used in Egeria)
maven {
url "https://maven.atlassian.com/3rdparty"
}
// uncomment to pick up from local ~/.m2 - but can be unpredictable. recommend to use maven central and snapshots
mavenLocal()
// Repository for custom IBM hive connector
if (project.hasProperty("ibmhms")) {
ivy {
url 'https://us.sql-query.cloud.ibm.com'
patternLayout {
artifact '/download/catalog/[artifact]-[revision]-sqlquery.[ext]'
}
// This is required in Gradle 6.0+ as metadata file (ivy.xml)
// is mandatory. Docs linked below this code section
metadataSources { artifact() }
}
}
// https://us.sql-query.cloud.ibm.com/download/catalog/hive-metastore-standalone-client-3.1.2-sqlquery.jar
}
// Project information
group = 'org.odpi.egeria'
version = '1.2-SNAPSHOT'
ext.name = 'Egeria Hive Metastore Connector'
description = 'Egeria Connector for Hive Metastore'
// Versions - most should be picked up from the import of the Egeria base POM
ext {
egeriaversion = '4.1-SNAPSHOT'
cachingconnectorversion = '1.2-SNAPSHOT'
hmsVersion3 = '3.1.3'
hmsVersion4 = '4.0.0-alpha-2'
ibmhmsVersion = '3.1.2'
hadoopVersion = '3.3.6'
hiveStorageVersion = '2.8.1'
thriftVersion = '0.18.0'
}
// Dependencies
dependencies {
// authoritative versions for dependencyManagement provided by Egeria core - this uses the dependencyManagement
// in the main Egeria pom to define the versions of the dependencies.
implementation platform("org.odpi.egeria:egeria:${egeriaversion}")
// Only used for build - already present in server chassis at runtime - similar to 'provided' with maven
compileOnly "com.fasterxml.jackson.core:jackson-databind"
compileOnly "com.fasterxml.jackson.core:jackson-annotations"
compileOnly "com.fasterxml.jackson.core:jackson-core"
compileOnly "org.springframework:spring-core"
compileOnly "org.odpi.egeria:audit-log-framework"
compileOnly "org.odpi.egeria:open-connector-framework"
compileOnly "org.odpi.egeria:open-metadata-types"
compileOnly "org.odpi.egeria:repository-services-implementation"
compileOnlyApi "org.odpi.egeria:repository-services-apis"
compileOnly "org.odpi.egeria:admin-services-api"
compileOnly "org.odpi.egeria:connector-configuration-factory"
compileOnly "org.odpi.egeria:egeria-connector-omrs-caching:${cachingconnectorversion}"
// Include at compile & runtime - to support use of connector
implementation "org.apache.hadoop:hadoop-common:${hadoopVersion}"
runtimeOnly 'org.apache.hadoop.thirdparty:hadoop-shaded-guava'
implementation 'org.apache.thrift:libthrift:${thriftVersion}'
// Use standard client library version by default, replace with an alternate library for IBM config
// and resolve some differences in dependencies
if (project.hasProperty("ibmhms")) {
api("com.ibm.hive:hive-metastore-standalone-client:${ibmhmsVersion}")
} else if (project.hasProperty("hmsv4")) {
// this is implementation not API, so that it brings in GetTableRequest, which is required at runtime by the hms client
// this is not using the variable for the version - I think something about the characters is not
// allowing me to - so I have hard coded for now.
implementation 'org.apache.hive:hive-standalone-metastore-common:4.0.0-beta-1'
} else {
api("org.apache.hive:hive-standalone-metastore:${hmsVersion3}")
testImplementation 'org.apache.hive:hive-storage-api:${hiveStorageVersion}'
}
// Only needed to compile test code
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
testImplementation 'org.junit.jupiter:junit-jupiter-api'
//testImplementation 'org.apache.hive:hive-storage-api:${hiveStorageVersion}'
testCompileOnly "org.odpi.egeria:egeria-connector-omrs-caching:${cachingconnectorversion}"
testRuntimeOnly "org.odpi.egeria:repository-services-apis"
testRuntimeOnly "org.odpi.egeria:egeria-connector-omrs-caching:${cachingconnectorversion}"
testCompileOnly "org.odpi.egeria:audit-log-framework"
testCompileOnly "org.odpi.egeria:open-connector-framework"
}
// Further refinement - Resolve some dependency clashes/issues
configurations.all {
// check for updates every build - critical when using Snapshots
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
// Resolve logging clashes - consistent with Egeria
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
exclude group: 'org.slf4j', module: 'slf4j-reload4j'
exclude group: 'ch.qos.reload4j', module: 'reload4j'
exclude group: 'org.apache.logging.log4j', module: 'log4j-slf4j-impl'
exclude group: 'log4j', module: 'log4j'
exclude group: 'commons-logging', module: 'commons-logging'
}
// Testing
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
reports {
html.required = true
}
filter {
includeTestsMatching "*Test"
}
}
// Maven Central (technically sonatype oss) requires we distribute source and javadoc.
// Also declare use of java 11 language & target
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
withJavadocJar()
withSourcesJar()
}
// More Java language settings & linting
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
sourceCompatibility = "17"
targetCompatibility = "17"
options.incremental = true
options.fork = true
options.failOnError = true
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
}
// For later java versions this is recommended - keep conditional in case we want to build on 8
javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
// Build an uber jar with dependencies.
shadowJar {
archiveClassifier = 'jar-with-dependencies'
// required as this hits a jar limit otherwise
zip64 true
// TODO: May not need to exclude, since we shade the dependencies
exclude("com/google/protobuf/**")
// strip what we don't need, but keep egeria classes (i.e. connector dependency - providers)
// If enabled will cause connector to fail when loading hadoop-commons. Disabling, as what else is dynamically loaded?
//minimize {
// exclude(dependency('org.odpi.egeria:.*:.*'))
//}
// Hive libraries contain a large dependency chain. We want to shade most, but not all,
// no wildcards, so have to list each one (or recode as expression). Also much quicker explicitly declaring for
// hadoop, kerby, yetus, jute, zookeeper, commons, curator, avro, calcite, thrift
relocate("org.apache", "org.odpi.openmetadata.shaded.apache")
// guava, common, re2j, gson
relocate("com.google", "org.odpi.openmetadata.shaded.google")
relocate("org.codehaus.stax2", "org.odpi.openmetadata.shaded.stax2")
relocate("org.xbill", "org.odpi.openmetadata.shaded.xbill")
relocate("com.ctc.wstx", "org.odpi.openmetadata.shaded.wstx")
relocate("com.sun", "org.odpi.openmetadata.shaded.sun")
// servlet, jdo, realtime, annotation - need to be explicit, or Hadoop Configuration will fail to load from java.javax.xml
relocate("javax.servlet", "org.odpi.openmetadata.shaded.javax.servlet")
relocate("javax.jdo", "org.odpi.openmetadata.shaded.javax.jdo")
relocate("javax.realtime", "org.odpi.openmetadata.shaded.javax.realtime")
relocate("javax.annotation", "org.odpi.openmetadata.shaded.javax.annotation")
relocate("org.xerial.snappy", "org.odpi.openmetadata.shaded.snappy")
relocate("com.fasterxml", "org.odpi.openmetadata.shaded.fasterxml")
relocate("org.codehaus", "org.odpi.openmetadata.shaded.codehaus")
relocate("javolution", "org.odpi.openmetadata.shaded.javolution")
relocate("com.facebook", "org.odpi.openmetadata.shaded.facebook")
relocate("org.joda", "org.odpi.openmetadata.shaded.joda")
}
// TODO Ensure we run checks (health) on final Jar, not initial
build.dependsOn shadowJar
build.dependsOn("buildHealth")
// We only have a single artifact for now - this additional metadata is
// required for publishing to maven central. Only doing signing in 'CI'
publishing {
publications {
connector(MavenPublication) {
from components.java
pom {
url = 'http://egeria.odpi.org'
licenses {
// Code
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
// Docs
license {
name = 'Creative Commons Attribution 4.0 International (CC BY 4.0)'
url = 'https://creativecommons.org/licenses/by/4.0'
}
}
developers {
developer {
id = 'planetf1'
name = 'Nigel Jones'
email = '[email protected]'
}
developer {
id = 'davidradl'
name = 'David Radley'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:git://github.com/odpi/egeria-connector-hivemetastore.git'
developerConnection = 'scm:git:ssh://github.com/odpi/egeria-connector-hivemetastore.git'
url = 'http://github.com/odpi/egeria-connector-hivemetastore/tree/main'
}
}
// Override the project name & description for the pom based on properties set in the child build.gradle (hard to default & required for maven central)
pom.withXml {
asNode().appendNode('name', "${project.ext.name}")
asNode().appendNode('description', "${project.description}")
}
}
}
// Release versions get pushed to staging area on maven central, snapshots to snapshot repo
// Secrets for credentials
if (System.getenv("CI")) {
repositories {
maven {
name = 'OSSRH'
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
// User token (under profile) on oss.sonatype.org
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_TOKEN")
}
}
}
}
}
// To publish to ossrh we need to sign the artifacts - only in CI
if (System.getenv("CI")) {
signing {
// This is the publication to sign
sign publishing.publications.connector
// gpg --export-secret-keys [email protected] | base64
def signingKey = System.getenv("OSSRH_GPG_PRIVATE_KEY")
// Passphrase for key
def signingPassword = System.getenv("OSSRH_GPG_PASSPHRASE")
// public key id (last 8 characters only) - note keys also need uploading to all the main registries
def signingKeyId = System.getenv("OSSRH_GPG_KEYID")
// We use these values from secrets rather than gradle.properties
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
}
}