build.gradle.kts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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.10.0"
  10. rootProject.extra["otelVersion"] = otelVersion
  11. // Need both BOM and -all
  12. val groovyVersion = "3.0.9"
  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. // wait to upgrade to jackson 2.13.x until after 2.13.1 is released
  26. // due to https://github.com/FasterXML/jackson-databind/issues/3328
  27. "com.fasterxml.jackson:jackson-bom:2.12.6",
  28. "com.google.guava:guava-bom:31.0.1-jre",
  29. "org.codehaus.groovy:groovy-bom:${groovyVersion}",
  30. "io.opentelemetry:opentelemetry-bom:${otelVersion}",
  31. "io.opentelemetry:opentelemetry-bom-alpha:${otelVersion}-alpha",
  32. "org.junit:junit-bom:5.8.2"
  33. )
  34. val DEPENDENCY_SETS = listOf(
  35. DependencySet(
  36. "com.google.auto.value",
  37. "1.8.1",
  38. listOf("auto-value", "auto-value-annotations")
  39. ),
  40. DependencySet(
  41. "com.google.errorprone",
  42. "2.10.0",
  43. listOf("error_prone_annotations", "error_prone_core")
  44. ),
  45. DependencySet(
  46. "io.prometheus",
  47. "0.12.0",
  48. listOf("simpleclient", "simpleclient_common", "simpleclient_httpserver")
  49. ),
  50. DependencySet(
  51. "net.bytebuddy",
  52. // When updating, also update conventions/build.gradle.kts
  53. "1.12.6",
  54. listOf("byte-buddy", "byte-buddy-dep", "byte-buddy-agent", "byte-buddy-gradle-plugin")
  55. ),
  56. DependencySet(
  57. "org.openjdk.jmh",
  58. "1.32",
  59. listOf("jmh-core", "jmh-generator-bytecode")
  60. ),
  61. DependencySet(
  62. "org.mockito",
  63. "3.11.1",
  64. listOf("mockito-core", "mockito-junit-jupiter")
  65. ),
  66. DependencySet(
  67. "org.slf4j",
  68. "1.7.30",
  69. listOf("slf4j-api", "slf4j-simple", "log4j-over-slf4j", "jcl-over-slf4j", "jul-to-slf4j")
  70. ),
  71. DependencySet(
  72. "org.testcontainers",
  73. "1.16.2",
  74. listOf("testcontainers", "junit-jupiter", "cassandra", "couchbase", "elasticsearch", "kafka", "localstack", "selenium")
  75. )
  76. )
  77. val DEPENDENCIES = listOf(
  78. "ch.qos.logback:logback-classic:1.2.3",
  79. "com.github.stefanbirkner:system-lambda:1.2.0",
  80. "com.github.stefanbirkner:system-rules:1.19.0",
  81. "com.google.auto.service:auto-service:1.0",
  82. "com.uber.nullaway:nullaway:0.9.1",
  83. "commons-beanutils:commons-beanutils:1.9.4",
  84. "commons-cli:commons-cli:1.4",
  85. "commons-codec:commons-codec:1.15",
  86. "commons-collections:commons-collections:3.2.2",
  87. "commons-digester:commons-digester:2.1",
  88. "commons-fileupload:commons-fileupload:1.4",
  89. "commons-io:commons-io:2.10.0",
  90. "commons-lang:commons-lang:2.6",
  91. "commons-logging:commons-logging:1.2",
  92. "commons-validator:commons-validator:1.7",
  93. "io.netty:netty:3.10.6.Final",
  94. "io.opentelemetry.proto:opentelemetry-proto:0.11.0-alpha",
  95. "org.assertj:assertj-core:3.22.0",
  96. "org.awaitility:awaitility:4.1.0",
  97. "com.google.code.findbugs:jsr305:3.0.2",
  98. "org.codehaus.groovy:groovy-all:${groovyVersion}",
  99. "org.objenesis:objenesis:3.2",
  100. "org.spockframework:spock-core:2.0-groovy-3.0",
  101. "org.spockframework:spock-junit4:2.0-groovy-3.0",
  102. "org.scala-lang:scala-library:2.11.12",
  103. "org.springframework.boot:spring-boot-dependencies:2.3.1.RELEASE",
  104. )
  105. javaPlatform {
  106. allowDependencies()
  107. }
  108. dependencies {
  109. for (bom in DEPENDENCY_BOMS) {
  110. api(enforcedPlatform(bom))
  111. val split = bom.split(':')
  112. dependencyVersions[split[0]] = split[2]
  113. }
  114. constraints {
  115. for (set in DEPENDENCY_SETS) {
  116. for (module in set.modules) {
  117. api("${set.group}:${module}:${set.version}")
  118. dependencyVersions[set.group] = set.version
  119. }
  120. }
  121. for (dependency in DEPENDENCIES) {
  122. api(dependency)
  123. val split = dependency.split(':')
  124. dependencyVersions[split[0]] = split[2]
  125. }
  126. }
  127. }
  128. fun isNonStable(version: String): Boolean {
  129. val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
  130. val regex = "^[0-9,.v-]+(-r)?$".toRegex()
  131. val isGuava = version.endsWith("-jre")
  132. val isStable = stableKeyword || regex.matches(version) || isGuava
  133. return isStable.not()
  134. }
  135. tasks {
  136. named<DependencyUpdatesTask>("dependencyUpdates") {
  137. revision = "release"
  138. checkConstraints = true
  139. rejectVersionIf {
  140. isNonStable(candidate.version)
  141. }
  142. }
  143. }