build.gradle.kts 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import net.ltgt.gradle.errorprone.errorprone
  2. plugins {
  3. id("otel.java-conventions")
  4. id("otel.publish-conventions")
  5. id("otel.jmh-conventions")
  6. }
  7. group = "io.opentelemetry.javaagent"
  8. dependencies {
  9. implementation(project(":javaagent-bootstrap"))
  10. implementation(project(":javaagent-extension-api"))
  11. implementation(project(":javaagent-tooling:javaagent-tooling-java9"))
  12. implementation(project(":instrumentation-api"))
  13. implementation(project(":instrumentation-annotations-support"))
  14. implementation(project(":muzzle"))
  15. implementation(project(":sdk-autoconfigure-support"))
  16. implementation("io.opentelemetry:opentelemetry-api")
  17. testImplementation("io.opentelemetry:opentelemetry-api-incubator")
  18. implementation("io.opentelemetry:opentelemetry-sdk")
  19. implementation("io.opentelemetry:opentelemetry-extension-kotlin")
  20. implementation("io.opentelemetry:opentelemetry-extension-trace-propagators")
  21. // the incubator's ViewConfigCustomizer is used to support loading yaml-based metric views
  22. implementation("io.opentelemetry:opentelemetry-sdk-extension-incubator") {
  23. // we use byte-buddy-dep
  24. exclude("net.bytebuddy", "byte-buddy")
  25. }
  26. // Exporters with dependencies
  27. implementation("io.opentelemetry:opentelemetry-exporter-logging")
  28. implementation("io.opentelemetry:opentelemetry-exporter-otlp")
  29. implementation("io.opentelemetry:opentelemetry-exporter-logging-otlp")
  30. implementation("io.opentelemetry:opentelemetry-exporter-prometheus")
  31. implementation("io.opentelemetry:opentelemetry-exporter-zipkin")
  32. implementation("io.opentelemetry:opentelemetry-sdk-extension-jaeger-remote-sampler")
  33. implementation("io.opentelemetry.contrib:opentelemetry-aws-xray-propagator")
  34. implementation("io.opentelemetry.contrib:opentelemetry-aws-resources")
  35. implementation("io.opentelemetry.contrib:opentelemetry-gcp-resources")
  36. api("net.bytebuddy:byte-buddy-dep")
  37. implementation("org.ow2.asm:asm-tree")
  38. implementation("org.ow2.asm:asm-util")
  39. annotationProcessor("com.google.auto.service:auto-service")
  40. compileOnly("com.google.auto.service:auto-service-annotations")
  41. testCompileOnly("com.google.auto.service:auto-service-annotations")
  42. // Used by byte-buddy but not brought in as a transitive dependency.
  43. compileOnly("com.google.code.findbugs:annotations")
  44. testCompileOnly("com.google.code.findbugs:annotations")
  45. testImplementation(project(":testing-common"))
  46. testImplementation("com.google.guava:guava")
  47. testImplementation("org.junit-pioneer:junit-pioneer")
  48. }
  49. testing {
  50. suites {
  51. val testExceptionHandler by registering(JvmTestSuite::class) {
  52. dependencies {
  53. implementation(project(":javaagent-bootstrap"))
  54. implementation(project(":javaagent-tooling"))
  55. implementation("net.bytebuddy:byte-buddy-dep")
  56. // Used by byte-buddy but not brought in as a transitive dependency.
  57. compileOnly("com.google.code.findbugs:annotations")
  58. }
  59. }
  60. val testMissingType by registering(JvmTestSuite::class) {
  61. dependencies {
  62. implementation(project(":javaagent-bootstrap"))
  63. implementation(project(":javaagent-tooling"))
  64. implementation("net.bytebuddy:byte-buddy-dep")
  65. compileOnly("com.google.guava:guava")
  66. // Used by byte-buddy but not brought in as a transitive dependency.
  67. compileOnly("com.google.code.findbugs:annotations")
  68. }
  69. }
  70. val testPatchBytecodeVersion by registering(JvmTestSuite::class) {
  71. dependencies {
  72. implementation(project(":javaagent-bootstrap"))
  73. implementation(project(":javaagent-tooling"))
  74. implementation("net.bytebuddy:byte-buddy-dep")
  75. // Used by byte-buddy but not brought in as a transitive dependency.
  76. compileOnly("com.google.code.findbugs:annotations")
  77. }
  78. }
  79. }
  80. }
  81. // Here we only include autoconfigure but don"t include OTLP exporters to ensure they are only in
  82. // the full distribution. We need to override the default exporter setting of OTLP as a result.
  83. tasks {
  84. withType<Test>().configureEach {
  85. environment("OTEL_TRACES_EXPORTER", "none")
  86. environment("OTEL_METRICS_EXPORTER", "none")
  87. // required on jdk17
  88. jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
  89. jvmArgs("--add-opens=java.base/java.util=ALL-UNNAMED")
  90. jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
  91. }
  92. // TODO this should live in jmh-conventions
  93. named<JavaCompile>("jmhCompileGeneratedClasses") {
  94. options.errorprone {
  95. isEnabled.set(false)
  96. }
  97. }
  98. check {
  99. dependsOn(testing.suites)
  100. }
  101. }
  102. // Mockito inline mocking uses byte-buddy but agent tooling currently uses byte-buddy-dep, which cannot be on the same
  103. // classpath. Disable inline mocking to prevent conflicts.
  104. // TODO(anuraaga): Find a better solution
  105. configurations {
  106. testRuntimeClasspath {
  107. dependencies {
  108. exclude("org.mockito", "mockito-inline")
  109. }
  110. }
  111. }