build.gradle.kts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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.15.0"
  10. rootProject.extra["otelVersion"] = otelVersion
  11. // Need both BOM and groovy jars
  12. val groovyVersion = "4.0.2"
  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. "org.testcontainers:testcontainers-bom:1.17.1",
  32. )
  33. val DEPENDENCY_SETS = listOf(
  34. DependencySet(
  35. "com.google.auto.service",
  36. "1.0.1",
  37. listOf("auto-service", "auto-service-annotations")
  38. ),
  39. DependencySet(
  40. "com.google.auto.value",
  41. "1.9",
  42. listOf("auto-value", "auto-value-annotations")
  43. ),
  44. DependencySet(
  45. "com.google.errorprone",
  46. "2.12.1",
  47. listOf("error_prone_annotations", "error_prone_core", "error_prone_test_helpers")
  48. ),
  49. DependencySet(
  50. "net.bytebuddy",
  51. // When updating, also update conventions/build.gradle.kts
  52. "1.12.10",
  53. listOf("byte-buddy", "byte-buddy-dep", "byte-buddy-agent", "byte-buddy-gradle-plugin")
  54. ),
  55. DependencySet(
  56. "org.openjdk.jmh",
  57. "1.35",
  58. listOf("jmh-core", "jmh-generator-bytecode")
  59. ),
  60. DependencySet(
  61. "org.mockito",
  62. "4.5.1",
  63. listOf("mockito-core", "mockito-junit-jupiter", "mockito-inline")
  64. ),
  65. DependencySet(
  66. "org.slf4j",
  67. "1.7.36",
  68. listOf("slf4j-api", "slf4j-simple", "log4j-over-slf4j", "jcl-over-slf4j", "jul-to-slf4j")
  69. ),
  70. )
  71. val DEPENDENCIES = listOf(
  72. "ch.qos.logback:logback-classic:1.2.11",
  73. "com.github.stefanbirkner:system-lambda:1.2.1",
  74. "com.github.stefanbirkner:system-rules:1.19.0",
  75. "uk.org.webcompere:system-stubs-jupiter:2.0.1",
  76. "com.uber.nullaway:nullaway:0.9.7",
  77. "commons-beanutils:commons-beanutils:1.9.4",
  78. "commons-cli:commons-cli:1.5.0",
  79. "commons-codec:commons-codec:1.15",
  80. "commons-collections:commons-collections:3.2.2",
  81. "commons-digester:commons-digester:2.1",
  82. "commons-fileupload:commons-fileupload:1.4",
  83. "commons-io:commons-io:2.11.0",
  84. "commons-lang:commons-lang:2.6",
  85. "commons-logging:commons-logging:1.2",
  86. "commons-validator:commons-validator:1.7",
  87. "io.netty:netty:3.10.6.Final",
  88. "io.opentelemetry.proto:opentelemetry-proto:0.17.0-alpha",
  89. "org.assertj:assertj-core:3.22.0",
  90. "org.awaitility:awaitility:4.2.0",
  91. "com.google.code.findbugs:annotations:3.0.1u2",
  92. "com.google.code.findbugs:jsr305:3.0.2",
  93. "org.apache.groovy:groovy:${groovyVersion}",
  94. "org.apache.groovy:groovy-json:${groovyVersion}",
  95. "org.junit-pioneer:junit-pioneer:1.7.0",
  96. "org.objenesis:objenesis:3.2",
  97. "org.spockframework:spock-core:2.2-M1-groovy-4.0",
  98. "org.spockframework:spock-junit4:2.2-M1-groovy-4.0",
  99. "org.scala-lang:scala-library:2.11.12",
  100. // Note that this is only referenced as "org.springframework.boot" in build files, not the artifact name.
  101. "org.springframework.boot:spring-boot-dependencies:2.3.1.RELEASE"
  102. )
  103. javaPlatform {
  104. allowDependencies()
  105. }
  106. dependencies {
  107. for (bom in DEPENDENCY_BOMS) {
  108. api(enforcedPlatform(bom))
  109. val split = bom.split(':')
  110. dependencyVersions[split[0]] = split[2]
  111. }
  112. constraints {
  113. for (set in DEPENDENCY_SETS) {
  114. for (module in set.modules) {
  115. api("${set.group}:${module}:${set.version}")
  116. dependencyVersions[set.group] = set.version
  117. }
  118. }
  119. for (dependency in DEPENDENCIES) {
  120. api(dependency)
  121. val split = dependency.split(':')
  122. dependencyVersions[split[0]] = split[2]
  123. }
  124. }
  125. }
  126. fun isNonStable(version: String): Boolean {
  127. val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
  128. val regex = "^[0-9,.v-]+(-r)?$".toRegex()
  129. val isGuava = version.endsWith("-jre")
  130. val isStable = stableKeyword || regex.matches(version) || isGuava
  131. return isStable.not()
  132. }
  133. tasks {
  134. named<DependencyUpdatesTask>("dependencyUpdates") {
  135. revision = "release"
  136. checkConstraints = true
  137. rejectVersionIf {
  138. isNonStable(candidate.version)
  139. }
  140. }
  141. }