build.gradle.kts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
  29. "--add-exports", "jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
  30. "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
  31. "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
  32. )
  33. )
  34. }
  35. }
  36. }
  37. tasks.withType<Test>().configureEach {
  38. // required on jdk17
  39. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED")
  40. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED")
  41. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED")
  42. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED")
  43. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED")
  44. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED")
  45. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED")
  46. jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED")
  47. jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
  48. }
  49. // Our conventions apply this project as a dependency in the errorprone configuration, which would cause
  50. // a circular dependency if trying to compile this project with that still there. So we filter this
  51. // project out.
  52. configurations {
  53. named("errorprone") {
  54. dependencies.removeIf {
  55. it is ProjectDependency && it.dependencyProject == project
  56. }
  57. }
  58. }