build.gradle.kts 5.2 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. val otelVersion = "1.12.0"
  10. rootProject.extra["otelVersion"] = otelVersion
  11. // Need both BOM and groovy jars
  12. val groovyVersion = "4.0.1"
  13. // We don't force libraries we instrument to new versions since we compile and test against specific
  14. // old baseline versions
  15. // but we do try to force those libraries' transitive dependencies to new versions where possible
  16. // so that we don't end up with explosion of dependency versions in Intellij, which causes
  17. // Intellij to spend lots of time indexing all of those different dependency versions,
  18. // and makes debugging painful because Intellij has no idea which dependency version's source
  19. // to use when stepping through code.
  20. //
  21. // Sometimes libraries we instrument do require a specific version of a transitive dependency
  22. // and 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.13.2.20220328",
  26. "com.google.guava:guava-bom:31.1-jre",
  27. "org.apache.groovy:groovy-bom:${groovyVersion}",
  28. "io.opentelemetry:opentelemetry-bom:${otelVersion}",
  29. "io.opentelemetry:opentelemetry-bom-alpha:${otelVersion}-alpha",
  30. "org.junit:junit-bom:5.8.2"
  31. )
  32. val DEPENDENCY_SETS = listOf(
  33. DependencySet(
  34. "com.google.auto.service",
  35. "1.0.1",
  36. listOf("auto-service", "auto-service-annotations")
  37. ),
  38. DependencySet(
  39. "com.google.auto.value",
  40. "1.9",
  41. listOf("auto-value", "auto-value-annotations")
  42. ),
  43. DependencySet(
  44. "com.google.errorprone",
  45. "2.10.0",
  46. listOf("error_prone_annotations", "error_prone_core", "error_prone_test_helpers")
  47. ),
  48. DependencySet(
  49. "net.bytebuddy",
  50. // When updating, also update conventions/build.gradle.kts
  51. "1.12.9",
  52. listOf("byte-buddy", "byte-buddy-dep", "byte-buddy-agent", "byte-buddy-gradle-plugin")
  53. ),
  54. DependencySet(
  55. "org.openjdk.jmh",
  56. "1.35",
  57. listOf("jmh-core", "jmh-generator-bytecode")
  58. ),
  59. DependencySet(
  60. "org.mockito",
  61. "4.4.0",
  62. listOf("mockito-core", "mockito-junit-jupiter", "mockito-inline")
  63. ),
  64. DependencySet(
  65. "org.slf4j",
  66. "1.7.36",
  67. listOf("slf4j-api", "slf4j-simple", "log4j-over-slf4j", "jcl-over-slf4j", "jul-to-slf4j")
  68. ),
  69. DependencySet(
  70. "org.testcontainers",
  71. "1.16.3",
  72. listOf("testcontainers", "junit-jupiter", "cassandra", "couchbase", "elasticsearch", "kafka", "localstack", "selenium")
  73. )
  74. )
  75. val DEPENDENCIES = listOf(
  76. "ch.qos.logback:logback-classic:1.2.11",
  77. "com.github.stefanbirkner:system-lambda:1.2.1",
  78. "com.github.stefanbirkner:system-rules:1.19.0",
  79. "uk.org.webcompere:system-stubs-jupiter:2.0.1",
  80. "com.uber.nullaway:nullaway:0.9.6",
  81. "commons-beanutils:commons-beanutils:1.9.4",
  82. "commons-cli:commons-cli:1.5.0",
  83. "commons-codec:commons-codec:1.15",
  84. "commons-collections:commons-collections:3.2.2",
  85. "commons-digester:commons-digester:2.1",
  86. "commons-fileupload:commons-fileupload:1.4",
  87. "commons-io:commons-io:2.11.0",
  88. "commons-lang:commons-lang:2.6",
  89. "commons-logging:commons-logging:1.2",
  90. "commons-validator:commons-validator:1.7",
  91. "io.netty:netty:3.10.6.Final",
  92. "io.opentelemetry.proto:opentelemetry-proto:0.11.0-alpha",
  93. "org.assertj:assertj-core:3.22.0",
  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.junit-pioneer:junit-pioneer:1.6.2",
  100. "org.objenesis:objenesis:3.2",
  101. "org.spockframework:spock-core:2.2-M1-groovy-4.0",
  102. "org.spockframework:spock-junit4:2.2-M1-groovy-4.0",
  103. "org.scala-lang:scala-library:2.11.12",
  104. // Note that this is only referenced as "org.springframework.boot" in build files, not the artifact name.
  105. "org.springframework.boot:spring-boot-dependencies:2.3.1.RELEASE"
  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 (set in DEPENDENCY_SETS) {
  118. for (module in set.modules) {
  119. api("${set.group}:${module}:${set.version}")
  120. dependencyVersions[set.group] = set.version
  121. }
  122. }
  123. for (dependency in DEPENDENCIES) {
  124. api(dependency)
  125. val split = dependency.split(':')
  126. dependencyVersions[split[0]] = split[2]
  127. }
  128. }
  129. }
  130. fun isNonStable(version: String): Boolean {
  131. val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
  132. val regex = "^[0-9,.v-]+(-r)?$".toRegex()
  133. val isGuava = version.endsWith("-jre")
  134. val isStable = stableKeyword || regex.matches(version) || isGuava
  135. return isStable.not()
  136. }
  137. tasks {
  138. named<DependencyUpdatesTask>("dependencyUpdates") {
  139. revision = "release"
  140. checkConstraints = true
  141. rejectVersionIf {
  142. isNonStable(candidate.version)
  143. }
  144. }
  145. }