build.gradle.kts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import kotlin.math.max
  2. plugins {
  3. id("otel.javaagent-testing")
  4. }
  5. dependencies {
  6. testInstrumentation(project(":instrumentation:executors:javaagent"))
  7. testCompileOnly(project(":instrumentation:executors:bootstrap"))
  8. testImplementation(project(":instrumentation:executors:testing"))
  9. }
  10. otelJava {
  11. // StructuredTaskScopeTest that uses preview feature, requires that the test is compiled for the
  12. // same vm version that is going to execute the test. Choose whichever is greater 21 or the
  13. // version of the vm that is going to run test
  14. val testJavaVersion =
  15. gradle.startParameter.projectProperties["testJavaVersion"]?.let(JavaVersion::toVersion)
  16. ?: JavaVersion.current()
  17. minJavaVersionSupported.set(JavaVersion.toVersion(max(
  18. testJavaVersion.majorVersion.toInt(),
  19. JavaVersion.VERSION_21.majorVersion.toInt()
  20. )))
  21. }
  22. tasks.withType<JavaCompile>().configureEach {
  23. with(options) {
  24. compilerArgs.add("--enable-preview")
  25. }
  26. }
  27. tasks.withType<Test>().configureEach {
  28. // needed for VirtualThreadTest
  29. jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
  30. jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
  31. // needed for structured concurrency test
  32. jvmArgs("--enable-preview")
  33. }