build.gradle.kts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. // Need both BOM and groovy jars
  10. val groovyVersion = "4.0.6"
  11. // We don't force libraries we instrument to new versions since we compile and test against specific
  12. // old baseline versions but we do try to force those libraries' transitive dependencies to new
  13. // versions where possible so that we don't end up with explosion of dependency versions in
  14. // Intellij, which causes Intellij to spend lots of time indexing all of those different dependency
  15. // versions, and makes debugging painful because Intellij has no idea which dependency version's
  16. // source to use when stepping through code.
  17. //
  18. // Sometimes libraries we instrument do require a specific version of a transitive dependency and
  19. // that can be applied in the specific instrumentation gradle file, e.g.
  20. // configurations.testRuntimeClasspath.resolutionStrategy.force "com.google.guava:guava:19.0"
  21. val DEPENDENCY_BOMS = listOf(
  22. "com.fasterxml.jackson:jackson-bom:2.14.0",
  23. "com.google.guava:guava-bom:31.1-jre",
  24. "org.apache.groovy:groovy-bom:${groovyVersion}",
  25. "io.opentelemetry:opentelemetry-bom:1.20.1",
  26. "io.opentelemetry:opentelemetry-bom-alpha:1.20.1-alpha",
  27. "org.junit:junit-bom:5.9.1",
  28. "org.testcontainers:testcontainers-bom:1.17.6",
  29. "org.spockframework:spock-bom:2.3-groovy-4.0"
  30. )
  31. val autoServiceVersion = "1.0.1"
  32. val autoValueVersion = "1.10.1"
  33. val errorProneVersion = "2.16"
  34. val byteBuddyVersion = "1.12.19"
  35. val jmhVersion = "1.36"
  36. val mockitoVersion = "4.9.0"
  37. val slf4jVersion = "2.0.4"
  38. val CORE_DEPENDENCIES = listOf(
  39. "com.google.auto.service:auto-service:${autoServiceVersion}",
  40. "com.google.auto.service:auto-service-annotations:${autoServiceVersion}",
  41. "com.google.auto.value:auto-value:${autoValueVersion}",
  42. "com.google.auto.value:auto-value-annotations:${autoValueVersion}",
  43. "com.google.errorprone:error_prone_annotations:${errorProneVersion}",
  44. "com.google.errorprone:error_prone_core:${errorProneVersion}",
  45. "com.google.errorprone:error_prone_test_helpers:${errorProneVersion}",
  46. // When updating, also update conventions/build.gradle.kts
  47. "net.bytebuddy:byte-buddy:${byteBuddyVersion}",
  48. "net.bytebuddy:byte-buddy-dep:${byteBuddyVersion}",
  49. "net.bytebuddy:byte-buddy-agent:${byteBuddyVersion}",
  50. "net.bytebuddy:byte-buddy-gradle-plugin:${byteBuddyVersion}",
  51. "org.openjdk.jmh:jmh-core:${jmhVersion}",
  52. "org.openjdk.jmh:jmh-generator-bytecode:${jmhVersion}",
  53. "org.mockito:mockito-core:${mockitoVersion}",
  54. "org.mockito:mockito-junit-jupiter:${mockitoVersion}",
  55. "org.mockito:mockito-inline:${mockitoVersion}",
  56. "org.slf4j:slf4j-api:${slf4jVersion}",
  57. "org.slf4j:slf4j-simple:${slf4jVersion}",
  58. "org.slf4j:log4j-over-slf4j:${slf4jVersion}",
  59. "org.slf4j:jcl-over-slf4j:${slf4jVersion}",
  60. "org.slf4j:jul-to-slf4j:${slf4jVersion}"
  61. )
  62. // See the comment above about why we keep this rather large list.
  63. // There are dependencies included here that appear to have no usages, but are maintained at
  64. // this top level to help consistently satisfy large numbers of transitive dependencies.
  65. val DEPENDENCIES = listOf(
  66. "ch.qos.logback:logback-classic:1.3.5", // 1.4+ requires Java 11+
  67. "com.github.stefanbirkner:system-lambda:1.2.1",
  68. "com.github.stefanbirkner:system-rules:1.19.0",
  69. "uk.org.webcompere:system-stubs-jupiter:2.0.1",
  70. "com.uber.nullaway:nullaway:0.10.5",
  71. "commons-beanutils:commons-beanutils:1.9.4",
  72. "commons-cli:commons-cli:1.5.0",
  73. "commons-codec:commons-codec:1.15",
  74. "commons-collections:commons-collections:3.2.2",
  75. "commons-digester:commons-digester:2.1",
  76. "commons-fileupload:commons-fileupload:1.4",
  77. "commons-io:commons-io:2.11.0",
  78. "commons-lang:commons-lang:2.6",
  79. "commons-logging:commons-logging:1.2",
  80. "commons-validator:commons-validator:1.7",
  81. "io.netty:netty:3.10.6.Final",
  82. "io.opentelemetry.contrib:opentelemetry-aws-xray-propagator:1.20.0-alpha",
  83. "io.opentelemetry.proto:opentelemetry-proto:0.19.0-alpha",
  84. "org.assertj:assertj-core:3.23.1",
  85. "org.awaitility:awaitility:4.2.0",
  86. "com.google.code.findbugs:annotations:3.0.1u2",
  87. "com.google.code.findbugs:jsr305:3.0.2",
  88. "org.apache.groovy:groovy:${groovyVersion}",
  89. "org.apache.groovy:groovy-json:${groovyVersion}",
  90. "org.codehaus.mojo:animal-sniffer-annotations:1.22",
  91. "org.junit-pioneer:junit-pioneer:1.9.0",
  92. "org.objenesis:objenesis:3.3",
  93. "org.scala-lang:scala-library:2.11.12",
  94. // Note that this is only referenced as "org.springframework.boot" in build files, not the artifact name.
  95. "org.springframework.boot:spring-boot-dependencies:2.7.5",
  96. "javax.validation:validation-api:2.0.1.Final",
  97. "org.yaml:snakeyaml:1.33"
  98. )
  99. javaPlatform {
  100. allowDependencies()
  101. }
  102. dependencies {
  103. for (bom in DEPENDENCY_BOMS) {
  104. api(enforcedPlatform(bom))
  105. val split = bom.split(':')
  106. dependencyVersions[split[0]] = split[2]
  107. }
  108. constraints {
  109. for (dependency in CORE_DEPENDENCIES) {
  110. api(dependency)
  111. val split = dependency.split(':')
  112. dependencyVersions[split[0]] = split[2]
  113. }
  114. for (dependency in DEPENDENCIES) {
  115. api(dependency)
  116. val split = dependency.split(':')
  117. dependencyVersions[split[0]] = split[2]
  118. }
  119. }
  120. }
  121. fun isNonStable(version: String): Boolean {
  122. val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
  123. val regex = "^[0-9,.v-]+(-r)?$".toRegex()
  124. val isGuava = version.endsWith("-jre")
  125. val isStable = stableKeyword || regex.matches(version) || isGuava
  126. return isStable.not()
  127. }
  128. tasks {
  129. named<DependencyUpdatesTask>("dependencyUpdates") {
  130. revision = "release"
  131. checkConstraints = true
  132. rejectVersionIf {
  133. isNonStable(candidate.version)
  134. }
  135. }
  136. }