build.gradle.kts 2.5 KB

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