This repository has been archived by the owner on Sep 4, 2023. It is now read-only.
forked from aws/aws-msk-iam-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
178 lines (150 loc) · 5.86 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
plugins {
id 'java-library'
id "io.freefair.lombok" version "5.3.0"
id 'com.github.johnrengelman.shadow' version '6.1.0'
id 'maven-publish'
id 'signing'
id 'org.owasp.dependencycheck' version '7.1.0.1'
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
java {
withSourcesJar()
withJavadocJar()
}
import java.nio.file.Paths
def readVersion() {
def versionPropsFile = file(Paths.get("src","main","resources","version.properties"))
if (versionPropsFile.canRead()) {
Properties versionProps = new Properties()
if (versionPropsFile.canRead()) {
versionProps.load(new FileInputStream(versionPropsFile))
}
versionProps['version']
} else {
throw new GradleException("Could not read version.properties!")
}
}
version = readVersion()
group "software.amazon.msk"
dependencies {
compileOnly('org.apache.kafka:kafka-clients:2.8.1')
// aws sdk imports.
implementation(platform('com.amazonaws:aws-java-sdk-bom:1.12.524'))
implementation('com.amazonaws:aws-java-sdk-core')
implementation('com.amazonaws:aws-java-sdk-sts')
implementation(platform('software.amazon.awssdk:bom:2.20.121'))
implementation('software.amazon.awssdk:auth')
implementation('software.amazon.awssdk:sso')
implementation('software.amazon.awssdk:sts')
implementation('com.fasterxml.jackson.core:jackson-databind:2.14.1')
implementation('org.slf4j:slf4j-api:1.7.25')
runtimeOnly('software.amazon.awssdk:apache-client')
//test dependencies
testImplementation('org.apache.kafka:kafka-clients:2.2.1',
'org.junit.jupiter:junit-jupiter-api:5.7.0',
'org.apache.commons:commons-lang3:3.11',
'org.mockito:mockito-inline:3.6.0')
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.7.0',
'org.apache.logging.log4j:log4j-core:2.17.1',
'org.apache.logging.log4j:log4j-slf4j-impl:2.17.1')
}
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
shadowJar {
//We remove org.slf4j from the configuration as it gets included transitively by multiple dependencies and just
//removing it from the configuration being shadowed is not sufficient.
configurations = [project.configurations.runtimeClasspath.exclude([group: "org.slf4j", module: "slf4j-api"])]
}
import java.util.jar.JarFile
class FilteredConfigureShadowRelocation extends ConfigureShadowRelocation {
@Input
Set<String> relocationFilterPrefix
@TaskAction
void configureRelocation() {
def packages = [] as Set<String>
configurations.each { configuration ->
configuration.files.each { jar ->
JarFile jf = new JarFile(jar)
jf.entries().each { entry ->
if (entry.name.endsWith(".class")) {
packages << entry.name[0..entry.name.lastIndexOf('/')-1].replaceAll('/', '.')
}
}
jf.close()
}
}
packages.each { pkg ->
def shouldRelocate = true
relocationFilterPrefix.each { prefix ->
if (pkg.startsWith(prefix)) {
shouldRelocate = false
}
}
if (shouldRelocate) {
target.relocate(pkg, "${prefix}.${pkg}")
}
}
}
}
task relocateShadowJar(type: FilteredConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = "aws_msk_iam_auth_shadow"
relocationFilterPrefix = ["org.slf4j", "software.amazon.awssdk"]
}
tasks.shadowJar.dependsOn tasks.relocateShadowJar
test {
useJUnitPlatform {
excludeTags 'ignored'
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = "Amazon MSK Library for AWS Identity and Access Management"
packaging = "jar"
url = "https://docs.aws.amazon.com/msk/latest/developerguide/iam-access-control.html"
description = "The Amazon MSK Library for AWS Identity and Access Management allows JVM based Apache " +
"Kafka clients to use AWS IAM for authentication and authorization against Amazon MSK " +
"clusters that have AWS IAM enabled as an authentication mechanism"
scm {
url = "https://github.com/aws/aws-msk-iam-auth"
connection = "scm:git:https://github.com/aws/aws-msk-iam-auth.git"
developerConnection = "scm:git:[email protected]:aws/aws-msk-iam-auth.git"
}
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "amazonwebservices"
organization = "Amazon Web Services"
organizationUrl = "https://aws.amazon.com"
}
}
}
}
}
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') : ""
}
}
}
}
signing {
def signingKey = project.hasProperty('signingKey') ? project.property('signingKey') : ""
def signingPassword = project.hasProperty('signingPassword') ? project.property('signingPassword') : ""
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}