forked from opensearch-project/security
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
397 lines (355 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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you 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.
*/
plugins {
id 'java'
id 'maven-publish'
id 'jacoco'
id 'checkstyle'
id "com.gorylenko.gradle-git-properties" version "2.3.2"
id 'org.gradle.crypto.checksum' version '1.1.0'
// Plugin prints gradle task graph, use following command: ./gradlew tiTree build
id 'org.barfuin.gradle.taskinfo' version '1.0.5'
id "nebula.ospackage" version "9.0.0"
id "com.google.osdetector" version "1.7.0"
id "org.gradle.test-retry" version "1.3.1"
}
import org.gradle.crypto.checksum.Checksum
import java.text.SimpleDateFormat
repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
ext {
default_opensearch_version = property("opensearch-core.version") + "-SNAPSHOT"
opensearch_version = System.getProperty("opensearch.version", default_opensearch_version)
buildVersionQualifier = System.getProperty("build.version_qualifier")
}
configurations.all {
resolutionStrategy {
force 'commons-codec:commons-codec:1.14'
force 'org.apache.santuario:xmlsec:2.2.3'
force 'org.cryptacular:cryptacular:1.1.4'
force 'net.minidev:json-smart:2.4.7'
force 'commons-cli:commons-cli:1.3.1'
force 'org.apache.httpcomponents:httpcore:4.4.12'
force "org.apache.commons:commons-lang3:3.4"
force "org.springframework:spring-core:5.3.14"
force "com.google.guava:guava:30.0-jre"
}
}
dependencies {
implementation 'jakarta.annotation:jakarta.annotation-api:1.3.5'
implementation "org.opensearch.plugin:transport-netty4-client:${opensearch_version}"
implementation "org.opensearch.client:opensearch-rest-high-level-client:${opensearch_version}"
implementation 'com.google.guava:guava:30.0-jre'
implementation 'org.greenrobot:eventbus:3.2.0'
implementation 'commons-cli:commons-cli:1.3.1'
implementation 'org.bouncycastle:bcprov-jdk15on:1.67'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.2'
implementation 'org.slf4j:slf4j-api:1.7.32'
implementation 'org.ldaptive:ldaptive:1.2.3'
implementation 'org.apache.httpcomponents:httpclient-cache:4.5.13'
implementation 'io.jsonwebtoken:jjwt-api:0.10.8'
implementation("org.apache.cxf:cxf-rt-rs-security-jose:3.4.5") {
exclude(group: 'jakarta.activation', module: 'jakarta.activation-api')
}
implementation 'com.github.wnameless:json-flattener:0.5.0'
implementation 'com.flipkart.zjsonpatch:zjsonpatch:0.4.4'
implementation 'org.apache.kafka:kafka-clients:2.8.1'
implementation 'com.onelogin:java-saml:2.5.0'
implementation ('org.opensaml:opensaml-saml-impl:3.4.5') {
exclude(group: 'org.apache.velocity', module: 'velocity')
}
implementation 'commons-lang:commons-lang:2.4'
implementation 'commons-collections:commons-collections:3.2.2'
implementation 'com.jayway.jsonpath:json-path:2.4.0'
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.10.8'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.10.8'
testImplementation "org.opensearch.plugin:reindex-client:${opensearch_version}"
testImplementation "org.opensearch:opensearch-ssl-config:${opensearch_version}"
testImplementation "org.opensearch.plugin:percolator-client:${opensearch_version}"
testImplementation "org.opensearch.plugin:lang-mustache-client:${opensearch_version}"
testImplementation "org.opensearch.plugin:parent-join-client:${opensearch_version}"
testImplementation "org.opensearch.plugin:aggs-matrix-stats-client:${opensearch_version}"
testImplementation 'org.apache.logging.log4j:log4j-core:2.17.1'
testImplementation 'commons-io:commons-io:2.7'
testImplementation 'org.hamcrest:hamcrest-all:1.3'
testImplementation 'junit:junit:4.13.1'
testImplementation 'org.apache.httpcomponents:fluent-hc:4.5.13'
testImplementation 'org.mockito:mockito-core:2.23.0'
testImplementation 'org.springframework.kafka:spring-kafka-test:2.7.9'
testImplementation 'javax.servlet:servlet-api:2.5'
testImplementation 'com.unboundid:unboundid-ldapsdk:4.0.9'
testImplementation 'com.github.stephenc.jcip:jcip-annotations:1.0-1'
testImplementation 'org.apache.kafka:kafka_2.13:2.8.1'
testImplementation 'org.apache.kafka:kafka_2.13:2.8.1:test'
testImplementation 'org.apache.kafka:kafka-clients:2.8.1:test'
compileOnly "org.opensearch:opensearch:${opensearch_version}"
}
ext {
securityPluginVersion = property('security-plugin.version')
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
}
group = 'org.opensearch'
version = securityPluginVersion
if (buildVersionQualifier) {
version += "-${buildVersionQualifier}"
}
if (isSnapshot) {
version += "-SNAPSHOT"
}
description = 'OpenSearch Security'
java.sourceCompatibility = JavaVersion.VERSION_11
java.targetCompatibility = JavaVersion.VERSION_11
tasks.register('testsJar', Jar) {
archiveClassifier = 'tests'
from(sourceSets.test.output)
}
publishing {
publications {
maven(MavenPublication) {
from(components.java)
artifact(testsJar)
}
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
static def getTimestamp() {
def df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(new Date())
}
static def gitCommitId() {
def cmd = "git rev-parse HEAD"
def proc = cmd.execute()
return proc.text.trim()
}
jar {
manifest {
attributes(
"Manifest-Version": "1.0",
"Created-By": "Gradle ${gradle.gradleVersion}",
"Build-Jdk": "${System.properties['java.version']}",
"Implementation-Title": "OpenSearch Security",
"Implementation-Version": archiveVersion,
"Implementation-Vendor-Id": "org.opensearch",
"Implementation-URL": "https://github.com/opensearch-project/security",
"Build-Time": getTimestamp(),
"Built-By": "OpenSearch Security Plugin",
"git-sha1": gitCommitId()
)
}
libsDirName = '.'
into '', {
from 'NOTICE.txt', "THIRD-PARTY.txt", "LICENSE"
}
processResources {
exclude("KEYS")
}
}
testsJar {
manifest {
attributes(
"Manifest-Version": "1.0",
"Created-By": "Gradle ${gradle.gradleVersion}",
"Build-Jdk": "${System.properties['java.version']}",
"Implementation-Title": "OpenSearch Security",
"Implementation-Version": archiveVersion,
"Implementation-Vendor-Id": "org.opensearch",
"Implementation-URL": "https://github.com/opensearch-project/security",
"Build-Time": getTimestamp(),
"Built-By": "OpenSearch Security Plugin",
"git-sha1": gitCommitId()
)
}
libsDirName = '.'
}
test {
maxParallelForks = 3
jvmArgs += "-Xmx3072m"
if (JavaVersion.current() > JavaVersion.VERSION_1_8) {
jvmArgs += "--add-opens=java.base/java.io=ALL-UNNAMED"
}
retry {
failOnPassedAfterRetry = false
maxFailures = 30
maxRetries = 5
}
jacoco {
excludes = [
"com.sun.jndi.dns.*",
"com.sun.security.sasl.gsskerb.*",
"java.sql.*",
"javax.script.*",
"org.jcp.xml.dsig.internal.dom.*",
"sun.nio.cs.ext.*",
"sun.security.ec.*",
"sun.security.jgss.*",
"sun.security.pkcs11.*",
"sun.security.smartcardio.*",
"sun.util.resources.provider.*"
]
}
}
gitProperties {
keys = [
'git.branch',
'git.build.version',
'git.closest.tag.commit.count',
'git.closest.tag.name',
'git.commit.id',
'git.commit.id.abbrev',
'git.commit.id.describe',
'git.commit.message.full',
'git.commit.message.short',
'git.commit.time',
'git.dirty',
'git.remote.origin.url',
'git.tags',
'git.total.commit.count'
]
}
// copied from: org.opensearch.gradle.dependencies.CompileOnlyResolvePlugin
project.getConfigurations().all { Configuration configuration ->
if (configuration.getName().equals(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME)) {
NamedDomainObjectProvider<Configuration> resolvableCompileOnly = project.getConfigurations().register('resolveableCompileOnly');
resolvableCompileOnly.configure { c ->
c.setCanBeResolved(true);
c.setCanBeConsumed(false);
c.extendsFrom(configuration);
};
}
};
task bundle(dependsOn: jar, type: Zip) {
from configurations.runtimeClasspath - project.configurations.getByName('resolveableCompileOnly')
from project.jar
from 'plugin-security.policy'
from 'plugin-descriptor.properties'
from('securityconfig') {
into 'securityconfig/'
}
from('tools') {
into 'tools/'
}
}
task bundleSecurityAdminStandalone(dependsOn: jar, type: Zip) {
archiveClassifier = 'securityadmin-standalone'
from(configurations.runtimeClasspath) {
into 'deps/'
}
from(project.jar) {
into 'deps/'
}
from('tools') {
into 'tools/'
}
from('securityconfig') {
into 'deps/securityconfig'
}
}
task bundleSecurityAdminStandaloneTarGz(dependsOn: jar, type: Tar) {
archiveClassifier = 'securityadmin-standalone'
archiveExtension = 'tar.gz'
compression = Compression.GZIP
from(configurations.runtimeClasspath) {
into 'deps/'
}
from(project.jar) {
into 'deps/'
}
from('tools') {
into 'tools/'
}
from('securityconfig') {
into 'deps/securityconfig'
}
}
task createPluginDescriptor() {
if (opensearch_version.contains("-SNAPSHOT")) {
opensearch_version=opensearch_version.substring(0, opensearch_version.length() - 9)
}
List<String> descriptorProperties = [
"description=Provide access control related features for OpenSearch",
"version=${version}",
"name=opensearch-security",
"classname=org.opensearch.security.OpenSearchSecurityPlugin",
"java.version=${java.targetCompatibility}",
"opensearch.version=${opensearch_version}",
]
new File("plugin-descriptor.properties").text = descriptorProperties.join ("\n")
}
bundle.doLast() {
new File("plugin-descriptor.properties").delete()
}
tasks.assemble.dependsOn(bundle)
tasks.bundle.dependsOn(createPluginDescriptor)
clean {
delete 'data/'
}
task createChecksums(type: Checksum) {
files = bundle.outputs.files
outputDir = new File(project.buildDir, "distributions")
algorithm = Checksum.Algorithm.SHA512
}
tasks.assemble.finalizedBy(createChecksums)
jacoco {
reportsDirectory = file("$buildDir/jacoco")
}
jacocoTestReport {
reports {
xml.required = true
}
}
tasks.test.finalizedBy(jacocoTestReport) // report is always generated after tests run
tasks.jacocoTestReport.dependsOn(test) // tests are required to run before generating the report
checkstyle {
configFile file("config/checkstyle/sun_checks.xml")
}
tasks.withType(Checkstyle) {
reports {
showViolations false
ignoreFailures = true
xml.required = true
html.required = true
}
}
buildRpm {
arch = 'NOARCH'
addParentDirs = false
archiveName "${packageName}-${version}.rpm"
}
buildDeb {
arch = 'all'
archiveName "${packageName}-${version}.deb"
}