build.gradle.kts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. plugins {
  2. id("otel.java-conventions")
  3. }
  4. dependencies {
  5. implementation("com.google.errorprone:error_prone_core")
  6. annotationProcessor("com.google.auto.service:auto-service")
  7. compileOnly("com.google.auto.service:auto-service-annotations")
  8. testImplementation("com.google.errorprone:error_prone_test_helpers")
  9. }
  10. otelJava {
  11. minJavaVersionSupported.set(JavaVersion.VERSION_11)
  12. }
  13. // We cannot use "--release" javac option here because that will forbid exporting com.sun.tools package.
  14. // We also can't seem to use the toolchain without the "--release" option. So disable everything.
  15. java {
  16. sourceCompatibility = JavaVersion.VERSION_11
  17. targetCompatibility = JavaVersion.VERSION_11
  18. toolchain {
  19. languageVersion.set(null as JavaLanguageVersion?)
  20. }
  21. }
  22. tasks {
  23. withType<JavaCompile>().configureEach {
  24. with(options) {
  25. release.set(null as Int?)
  26. compilerArgs.addAll(
  27. listOf(
  28. "--add-exports",
  29. "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
  30. "--add-exports",
  31. "jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
  32. "--add-exports",
  33. "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
  34. "--add-exports",
  35. "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
  36. )
  37. )
  38. }
  39. }
  40. }
  41. tasks.withType<Test>().configureEach {
  42. // required on jdk17
  43. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED")
  44. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED")
  45. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED")
  46. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED")
  47. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED")
  48. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED")
  49. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED")
  50. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED")
  51. jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
  52. }
  53. // Our conventions apply this project as a dependency in the errorprone configuration, which would cause
  54. // a circular dependency if trying to compile this project with that still there. So we filter this
  55. // project out.
  56. configurations {
  57. named("errorprone") {
  58. dependencies.removeIf {
  59. it is ProjectDependency && it.dependencyProject == project
  60. }
  61. }
  62. }