build.gradle.kts 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
  2. plugins {
  3. `java-platform`
  4. id("com.github.ben-manes.versions")
  5. }
  6. data class DependencySet(val group: String, val version: String, val modules: List<String>)
  7. val dependencyVersions = hashMapOf<String, String>()
  8. rootProject.extra["versions"] = dependencyVersions
  9. // this line is managed by .github/scripts/update-sdk-version.sh
  10. val otelSdkVersion = "1.29.0"
  11. val otelSdkAlphaVersion = otelSdkVersion.replaceFirst("(-SNAPSHOT)?$".toRegex(), "-alpha$1")
  12. // Need both BOM and groovy jars
  13. val groovyVersion = "4.0.13"
  14. // We don't force libraries we instrument to new versions since we compile and test against specific
  15. // old baseline versions but we do try to force those libraries' transitive dependencies to new
  16. // versions where possible so that we don't end up with explosion of dependency versions in
  17. // Intellij, which causes Intellij to spend lots of time indexing all of those different dependency
  18. // versions, and makes debugging painful because Intellij has no idea which dependency version's
  19. // source to use when stepping through code.
  20. //
  21. // Sometimes libraries we instrument do require a specific version of a transitive dependency and
  22. // that can be applied in the specific instrumentation gradle file, e.g.
  23. // configurations.testRuntimeClasspath.resolutionStrategy.force "com.google.guava:guava:19.0"
  24. val DEPENDENCY_BOMS = listOf(
  25. "com.fasterxml.jackson:jackson-bom:2.15.2",
  26. "com.squareup.okio:okio-bom:3.5.0", // see https://github.com/open-telemetry/opentelemetry-java/issues/5637
  27. "com.google.guava:guava-bom:32.1.2-jre",
  28. "org.apache.groovy:groovy-bom:${groovyVersion}",
  29. "io.opentelemetry:opentelemetry-bom:${otelSdkVersion}",
  30. "io.opentelemetry:opentelemetry-bom-alpha:${otelSdkAlphaVersion}",
  31. "org.junit:junit-bom:5.10.0",
  32. "org.testcontainers:testcontainers-bom:1.18.3",
  33. "org.spockframework:spock-bom:2.4-M1-groovy-4.0"
  34. )
  35. val autoServiceVersion = "1.1.1"
  36. val autoValueVersion = "1.10.3"
  37. val errorProneVersion = "2.21.1"
  38. val byteBuddyVersion = "1.14.6"
  39. val asmVersion = "9.5"
  40. val jmhVersion = "1.37"
  41. val mockitoVersion = "4.11.0"
  42. val slf4jVersion = "2.0.7"
  43. val CORE_DEPENDENCIES = listOf(
  44. "com.google.auto.service:auto-service:${autoServiceVersion}",
  45. "com.google.auto.service:auto-service-annotations:${autoServiceVersion}",
  46. "com.google.auto.value:auto-value:${autoValueVersion}",
  47. "com.google.auto.value:auto-value-annotations:${autoValueVersion}",
  48. "com.google.errorprone:error_prone_annotations:${errorProneVersion}",
  49. "com.google.errorprone:error_prone_core:${errorProneVersion}",
  50. "com.google.errorprone:error_prone_test_helpers:${errorProneVersion}",
  51. // When updating, also update conventions/build.gradle.kts
  52. "net.bytebuddy:byte-buddy:${byteBuddyVersion}",
  53. "net.bytebuddy:byte-buddy-dep:${byteBuddyVersion}",
  54. "net.bytebuddy:byte-buddy-agent:${byteBuddyVersion}",
  55. "net.bytebuddy:byte-buddy-gradle-plugin:${byteBuddyVersion}",
  56. "org.ow2.asm:asm:${asmVersion}",
  57. "org.ow2.asm:asm-tree:${asmVersion}",
  58. "org.ow2.asm:asm-util:${asmVersion}",
  59. "org.openjdk.jmh:jmh-core:${jmhVersion}",
  60. "org.openjdk.jmh:jmh-generator-bytecode:${jmhVersion}",
  61. "org.mockito:mockito-core:${mockitoVersion}",
  62. "org.mockito:mockito-junit-jupiter:${mockitoVersion}",
  63. "org.mockito:mockito-inline:${mockitoVersion}",
  64. "org.slf4j:slf4j-api:${slf4jVersion}",
  65. "org.slf4j:slf4j-simple:${slf4jVersion}",
  66. "org.slf4j:log4j-over-slf4j:${slf4jVersion}",
  67. "org.slf4j:jcl-over-slf4j:${slf4jVersion}",
  68. "org.slf4j:jul-to-slf4j:${slf4jVersion}"
  69. )
  70. // See the comment above about why we keep this rather large list.
  71. // There are dependencies included here that appear to have no usages, but are maintained at
  72. // this top level to help consistently satisfy large numbers of transitive dependencies.
  73. val DEPENDENCIES = listOf(
  74. "io.r2dbc:r2dbc-proxy:1.1.2.RELEASE",
  75. "ch.qos.logback:logback-classic:1.3.8", // 1.4+ requires Java 11+
  76. "com.github.stefanbirkner:system-lambda:1.2.1",
  77. "com.github.stefanbirkner:system-rules:1.19.0",
  78. "uk.org.webcompere:system-stubs-jupiter:2.0.2",
  79. "com.uber.nullaway:nullaway:0.10.12",
  80. "commons-beanutils:commons-beanutils:1.9.4",
  81. "commons-cli:commons-cli:1.5.0",
  82. "commons-codec:commons-codec:1.16.0",
  83. "commons-collections:commons-collections:3.2.2",
  84. "commons-digester:commons-digester:2.1",
  85. "commons-fileupload:commons-fileupload:1.5",
  86. "commons-io:commons-io:2.13.0",
  87. "commons-lang:commons-lang:2.6",
  88. "commons-logging:commons-logging:1.2",
  89. "commons-validator:commons-validator:1.7",
  90. "io.netty:netty:3.10.6.Final",
  91. "io.opentelemetry.contrib:opentelemetry-aws-xray-propagator:1.28.0-alpha",
  92. "io.opentelemetry.proto:opentelemetry-proto:1.0.0-alpha",
  93. "org.assertj:assertj-core:3.24.2",
  94. "org.awaitility:awaitility:4.2.0",
  95. "com.google.code.findbugs:annotations:3.0.1u2",
  96. "com.google.code.findbugs:jsr305:3.0.2",
  97. "org.apache.groovy:groovy:${groovyVersion}",
  98. "org.apache.groovy:groovy-json:${groovyVersion}",
  99. "org.codehaus.mojo:animal-sniffer-annotations:1.23",
  100. "org.junit-pioneer:junit-pioneer:1.9.1",
  101. "org.objenesis:objenesis:3.3",
  102. // Note that this is only referenced as "org.springframework.boot" in build files, not the artifact name.
  103. "org.springframework.boot:spring-boot-dependencies:2.7.14",
  104. "javax.validation:validation-api:2.0.1.Final",
  105. "org.snakeyaml:snakeyaml-engine:2.6"
  106. )
  107. javaPlatform {
  108. allowDependencies()
  109. }
  110. dependencies {
  111. for (bom in DEPENDENCY_BOMS) {
  112. api(enforcedPlatform(bom))
  113. val split = bom.split(':')
  114. dependencyVersions[split[0]] = split[2]
  115. }
  116. constraints {
  117. for (dependency in CORE_DEPENDENCIES) {
  118. api(dependency)
  119. val split = dependency.split(':')
  120. dependencyVersions[split[0]] = split[2]
  121. }
  122. for (dependency in DEPENDENCIES) {
  123. api(dependency)
  124. val split = dependency.split(':')
  125. dependencyVersions[split[0]] = split[2]
  126. }
  127. }
  128. }
  129. fun isNonStable(version: String): Boolean {
  130. val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
  131. val regex = "^[0-9,.v-]+(-r)?$".toRegex()
  132. val isGuava = version.endsWith("-jre")
  133. val isStable = stableKeyword || regex.matches(version) || isGuava
  134. return isStable.not()
  135. }
  136. tasks {
  137. named<DependencyUpdatesTask>("dependencyUpdates") {
  138. revision = "release"
  139. checkConstraints = true
  140. rejectVersionIf {
  141. isNonStable(candidate.version)
  142. }
  143. }
  144. }