-
Notifications
You must be signed in to change notification settings - Fork 18
/
build.gradle.kts
198 lines (164 loc) · 6.99 KB
/
build.gradle.kts
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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
plugins {
id("com.github.johnrengelman.shadow") apply false
id("nebula.release")
id("io.github.gradle-nexus.publish-plugin")
id("com.github.ben-manes.versions")
}
// Expose DiSCo & X-Ray SDK version to subprojects
val discoVersion by extra("0.11.0")
val xraySdkVersion by extra("2.9.1")
val awsSdkV1Version by extra("1.11.1031")
val awsSdkV2Version by extra("2.16.76")
val releaseTask = tasks.named("release")
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://aws.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://aws.oss.sonatype.org/content/repositories/snapshots/"))
username.set(System.getenv("SONATYPE_USERNAME"))
password.set(System.getenv("SONATYPE_PASSWORD"))
}
}
}
nebulaRelease {
addReleaseBranchPattern("main")
}
tasks.named<DependencyUpdatesTask>("dependencyUpdates").configure {
checkForGradleUpdate = true
outputDir = "build/dependencyUpdates"
reportfileName = "report"
}
allprojects {
group = "com.amazonaws"
repositories {
mavenCentral()
mavenLocal()
}
// Configure the shadow jar task, which does shading, to run after Gradle runs the jar task
pluginManager.withPlugin("com.github.johnrengelman.shadow") {
tasks {
named<DefaultTask>("assemble") {
dependsOn(named("shadowJar"))
}
named<ShadowJar>("shadowJar") {
// Suppress the "-all" suffix on the jar name, simply replace the default built jar instead
archiveClassifier.set("")
}
// Disable the conventional JAR task, and only run shadowJar instead
named<Jar>("jar") {
enabled = false
dependsOn(named("shadowJar"))
}
}
}
plugins.withId("java") {
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
dependencies {
// BOMs for common projects
add("implementation", platform("com.amazonaws:aws-xray-recorder-sdk-bom:${xraySdkVersion}"))
add("implementation", platform("software.amazon.disco:disco-toolkit-bom:${discoVersion}"))
add("implementation", platform("com.fasterxml.jackson:jackson-bom:2.11.0"))
add("implementation", platform("com.amazonaws:aws-java-sdk-bom:${awsSdkV1Version}"))
add("implementation", platform("software.amazon.awssdk:bom:${awsSdkV2Version}"))
// TODO: Add build step for running Null checker
add("compileOnly", "org.checkerframework:checker-qual:3.4.1")
// Common test dependencies
add("testImplementation", "junit:junit:4.12")
add("testImplementation", "org.assertj:assertj-core:3.16.1")
add("testImplementation", "org.mockito:mockito-core:2.28.2")
add("testImplementation", "org.checkerframework:checker-qual:3.4.1")
}
}
plugins.withId("maven-publish") {
plugins.apply("signing")
afterEvaluate {
val publishTask = tasks.named("publishToSonatype")
releaseTask.configure {
dependsOn(publishTask)
}
}
// Disable publishing a bunch of unnecessary Gradle metadata files
tasks.withType<GenerateModuleMetadata> {
enabled = false
}
// Defer maven publish until the assemble task has finished, giving time for shadowJar to complete if present
tasks.withType<AbstractPublishToMaven> {
dependsOn(tasks.named<DefaultTask>("assemble"))
}
plugins.withId("java") {
//create a task to publish our sources
tasks.register<Jar>("sourcesJar") {
from(project.the<SourceSetContainer>()["main"].allJava)
archiveClassifier.set("sources")
}
//create a task to publish javadoc
tasks.register<Jar>("javadocJar") {
from(tasks.named<Javadoc>("javadoc"))
archiveClassifier.set("javadoc")
}
}
configure<PublishingExtension> {
publications {
register<MavenPublication>("maven") {
// We only publish the Agent plugin jar to maven central
plugins.withId("com.github.johnrengelman.shadow") {
artifact(tasks.named<Jar>("shadowJar").get())
}
artifact(tasks["sourcesJar"])
artifact(tasks["javadocJar"])
versionMapping {
allVariants {
fromResolutionResult()
}
}
pom {
afterEvaluate {
pom.name.set(project.description)
}
description.set("The AWS X-Ray Auto-Instrumentation Agent for Java is a Java agent that " +
"automatically instruments your code to use X-Ray tracing.")
url.set("https://aws.amazon.com/documentation/xray/")
licenses {
license {
name.set("Apache License, Version 2.0")
url.set("https://aws.amazon.com/apache2.0")
distribution.set("repo")
}
}
developers {
developer {
id.set("amazonwebservices")
organization.set("Amazon Web Services")
organizationUrl.set("https://aws.amazon.com")
roles.add("developer")
}
developer {
id.set("armiros")
name.set("William Armiros")
email.set("[email protected]")
}
}
scm {
url.set("https://github.com/aws/aws-xray-java-agent.git")
}
}
}
}
}
tasks.withType<Sign>().configureEach {
onlyIf { System.getenv("CI") == "true" }
}
configure<SigningExtension> {
val signingKeyId = System.getenv("GPG_KEY_ID")
val signingKey = System.getenv("GPG_PRIVATE_KEY")
val signingPassword = System.getenv("GPG_PASSWORD")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign(the<PublishingExtension>().publications["maven"])
}
}
}