-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathbuild.gradle.kts
133 lines (117 loc) · 3.9 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
/*
* Copyright Amazon.com, Inc. or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.
*/
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import com.github.jk1.license.LicenseReportExtension
plugins {
`java-platform`
id("com.github.ben-manes.versions")
}
data class DependencySet(val group: String, val version: String, val modules: List<String>)
val testSnapshots = rootProject.findProperty("testUpstreamSnapshots") == "true"
// This is the version of the upstream instrumentation BOM
val otelVersion = "2.10.0-adot1"
val otelSnapshotVersion = "2.11.0"
val otelAlphaVersion = if (!testSnapshots) "$otelVersion-alpha" else "$otelSnapshotVersion-alpha-SNAPSHOT"
val otelJavaAgentVersion = if (!testSnapshots) otelVersion else "$otelSnapshotVersion-SNAPSHOT"
// All versions below are only used in testing and do not affect the released artifact.
val dependencyBoms = listOf(
"com.amazonaws:aws-java-sdk-bom:1.12.599",
"com.fasterxml.jackson:jackson-bom:2.16.0",
"com.google.guava:guava-bom:33.0.0-jre",
"com.google.protobuf:protobuf-bom:3.25.1",
"com.linecorp.armeria:armeria-bom:1.26.4",
"io.grpc:grpc-bom:1.59.1",
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:$otelAlphaVersion",
"org.apache.logging.log4j:log4j-bom:2.21.1",
"org.junit:junit-bom:5.10.1",
"org.springframework.boot:spring-boot-dependencies:2.7.17",
"org.testcontainers:testcontainers-bom:1.19.3",
"software.amazon.awssdk:bom:2.21.33",
)
val dependencySets = listOf(
DependencySet(
"org.assertj",
"3.24.2",
listOf("assertj-core"),
),
DependencySet(
"org.curioswitch.curiostack",
"2.2.0",
listOf("protobuf-jackson"),
),
DependencySet(
"org.slf4j",
"1.7.36",
listOf(
"slf4j-api",
"slf4j-simple",
),
),
)
val dependencyLists = listOf(
"commons-logging:commons-logging:1.2",
"com.sparkjava:spark-core:2.9.4",
"com.squareup.okhttp3:okhttp:4.12.0",
"io.opentelemetry.contrib:opentelemetry-aws-xray:1.39.0",
"io.opentelemetry.contrib:opentelemetry-aws-resources:1.39.0-alpha",
"io.opentelemetry.proto:opentelemetry-proto:1.0.0-alpha",
"io.opentelemetry.javaagent:opentelemetry-javaagent:$otelJavaAgentVersion",
"io.opentelemetry:opentelemetry-extension-aws:1.20.1",
"net.bytebuddy:byte-buddy:1.14.10",
)
javaPlatform {
allowDependencies()
}
dependencies {
for (bom in dependencyBoms) {
api(platform(bom))
}
constraints {
for (set in dependencySets) {
for (module in set.modules) {
api("${set.group}:$module:${set.version}")
}
}
for (dependency in dependencyLists) {
api(dependency)
}
}
}
rootProject.allprojects {
plugins.withId("com.github.jk1.dependency-license-report") {
configure<LicenseReportExtension> {
val bomExcludes = dependencyBoms.stream()
.map { it.substring(0, it.lastIndexOf(':')) }
.toArray { length -> arrayOfNulls<String>(length) }
excludes = bomExcludes
}
}
}
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
val regex = "^[0-9,.v-]+(-r|-alpha)?$".toRegex()
val isGuava = version.endsWith("-jre")
val isStable = stableKeyword || regex.matches(version) || isGuava
return isStable.not()
}
tasks {
named<DependencyUpdatesTask>("dependencyUpdates") {
revision = "release"
checkConstraints = true
rejectVersionIf {
isNonStable(candidate.version)
}
}
}