forked from opensearch-project/sql-jdbc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
248 lines (213 loc) · 7.72 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
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
buildscript {
repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
}
}
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '4.0.1'
id 'jacoco'
id 'maven'
id 'maven-publish'
id 'signing'
}
group 'org.opensearch.driver'
// keep version in sync with version in Driver source
version '1.4.0.0'
boolean snapshot = "true".equals(System.getProperty("build.snapshot", "false"));
if (snapshot) {
version += "-SNAPSHOT"
}
jacoco {
toolVersion = "0.8.3"
}
sourceCompatibility = 8
targetCompatibility = 8
repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
}
dependencies {
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "2.13.4.2"
implementation group: 'com.amazonaws', name: 'aws-java-sdk-core', version: '1.12.1'
testImplementation('org.junit.jupiter:junit-jupiter-api:5.3.1')
testImplementation('org.junit.jupiter:junit-jupiter-params:5.3.1')
testImplementation('com.github.tomakehurst:wiremock:3.0.0-beta-2')
testImplementation('org.mockito:mockito-core:2.23.0')
testImplementation('org.junit.jupiter:junit-jupiter-engine:5.3.1')
testImplementation('org.junit-pioneer:junit-pioneer:0.3.0')
testImplementation('org.eclipse.jetty:jetty-server:11.0.14')
// Enforce wiremock to use latest guava and json-smart
testImplementation('com.google.guava:guava:32.0.1-jre')
testImplementation('net.minidev:json-smart:2.4.9')
testRuntimeOnly('org.slf4j:slf4j-simple:1.7.25') // capture WireMock logging
// JDBC drivers for comparison test. Somehow Apache Derby throws security permission exception.
testImplementation fileTree('/build/libs') {
include '*.jar'
builtBy 'compileJdbc'
}
testImplementation group: 'org.xerial', name: 'sqlite-jdbc', version: '3.41.2.2'
testImplementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9'
}
task compileJdbc(type: Exec) {
if (DefaultNativePlatform.getCurrentOperatingSystem().isWindows()) {
commandLine './gradlew.bat', 'build'
commandLine './gradlew.bat', 'shadowJar'
} else {
commandLine './gradlew', 'build'
commandLine './gradlew', 'shadowJar'
}
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
}
static def getShadowPath(String path) {
return 'org.opensearch.sql.jdbc.shadow.' + path
}
shadowJar {
baseName = rootProject.name
classifier = ''
exclude 'META-INF/maven/commons-*/**'
exclude 'META-INF/maven/org.apache.*/**'
exclude 'META-INF/maven/joda-time/**'
exclude 'META-INF/maven/com.fasterxml.*/**'
exclude 'META-INF/services/com.fasterxml.*'
exclude 'META-INF/services/org.apache.logging*/**'
exclude 'META-INF/maven/com.amazonaws/**'
exclude 'META-INF/maven/software.amazon.*/**'
exclude 'META-INF/LICENSE*'
exclude 'META-INF/NOTICE*'
exclude 'META-INF/DEPENDENCIES'
relocate 'com.amazonaws', getShadowPath('com.amazonaws')
relocate 'org.apache', getShadowPath('org.apache')
relocate 'org.joda', getShadowPath('org.joda')
relocate 'com.fasterxml', getShadowPath('com.fasterxml')
relocate 'software.amazon', getShadowPath('software.amazon')
}
test {
useJUnitPlatform()
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar) {
classifier "javadoc"
from javadoc.destinationDir
}
publishing {
publications {
shadow(MavenPublication) { publication ->
project.shadow.component(publication)
artifact sourcesJar
artifact javadocJar
pom {
name = "OpenSearch SQL JDBC Driver"
packaging = "jar"
url = "https://github.com/opensearch-project/sql-jdbc"
description = "OpenSearch SQL JDBC driver"
scm {
connection = "scm:git@github.com:opensearch-project/sql-jdbc.git"
developerConnection = "scm:git@github.com:opensearch-project/sql-jdbc.git"
url = "git@github.com:opensearch-project/sql-jdbc.git"
}
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
name = 'OpenSearch'
url = 'https://github.com/opensearch-project/sql-jdbc'
}
}
}
}
publishMaven(MavenPublication) { publication ->
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = "OpenSearch SQL JDBC Driver"
packaging = "jar"
url = "https://github.com/opensearch-project/sql-jdbc"
description = "OpenSearch SQL JDBC driver"
scm {
connection = "scm:git@github.com:opensearch-project/sql-jdbc.git"
developerConnection = "scm:git@github.com:opensearch-project/sql-jdbc.git"
url = "git@github.com:opensearch-project/sql-jdbc.git"
}
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
name = 'OpenSearch'
url = 'https://github.com/opensearch-project/sql-jdbc'
}
}
}
}
}
repositories {
maven {
name = "sonatype-staging"
url "https://aws.oss.sonatype.org/service/local/staging/deploy/maven2"
credentials {
username project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : ''
password project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : ''
}
}
maven {
name = "localRepo"
url "${project.buildDir}/repository"
}
}
// TODO - enabled debug logging for the time being, remove this eventually
gradle.startParameter.setShowStacktrace(ShowStacktrace.ALWAYS)
gradle.startParameter.setLogLevel(LogLevel.DEBUG)
}
signing {
required { gradle.taskGraph.hasTask("publishShadowPublicationToSonatype-stagingRepository") }
sign publishing.publications.shadow
}
jacoco {
toolVersion = "0.8.3"
}
jacocoTestReport {
reports {
html.enabled true
}
}
test.finalizedBy(project.tasks.jacocoTestReport)
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.4
}
}
}
}
configurations.all {
// fixes https://www.mend.io/vulnerability-database/CVE-2023-24998
resolutionStrategy.force 'commons-fileupload:commons-fileupload:1.5'
resolutionStrategy.force 'org.eclipse.jetty:jetty-client:11.0.14'
resolutionStrategy.force 'org.eclipse.jetty:jetty-servlets:11.0.14'
resolutionStrategy.force 'org.eclipse.jetty:jetty-webapp:11.0.14'
}
check.dependsOn jacocoTestCoverageVerification