build.gradle.kts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import com.google.cloud.tools.jib.gradle.JibTask
  2. import java.time.LocalDateTime
  3. import java.time.format.DateTimeFormatter
  4. buildscript {
  5. dependencies {
  6. classpath("com.google.cloud.tools:jib-quarkus-extension-gradle:0.1.2")
  7. }
  8. }
  9. plugins {
  10. id("otel.java-conventions")
  11. id("com.google.cloud.tools.jib")
  12. id("io.quarkus") version "3.11.2"
  13. }
  14. dependencies {
  15. implementation(enforcedPlatform("io.quarkus:quarkus-bom:3.11.2"))
  16. implementation("io.quarkus:quarkus-resteasy")
  17. }
  18. quarkus {
  19. // Expected by jib extension.
  20. // TODO(anuraaga): Switch to quarkus plugin native jib support.
  21. setFinalName("opentelemetry-quarkus-$version")
  22. }
  23. val targetJDK = project.findProperty("targetJDK") ?: "11"
  24. val tag = findProperty("tag")
  25. ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now())
  26. java {
  27. // this is needed to avoid jib failing with
  28. // "Your project is using Java 17 but the base image is for Java 8"
  29. // (it seems the jib plugins does not understand toolchains yet)
  30. sourceCompatibility = JavaVersion.VERSION_1_8
  31. targetCompatibility = JavaVersion.VERSION_1_8
  32. }
  33. jib {
  34. from.image = "eclipse-temurin:$targetJDK"
  35. to.image = "ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-quarkus:jdk$targetJDK-$tag"
  36. container {
  37. mainClass = "bogus" // to suppress Jib warning about missing main class
  38. }
  39. pluginExtensions {
  40. pluginExtension {
  41. implementation = "com.google.cloud.tools.jib.gradle.extension.quarkus.JibQuarkusExtension"
  42. }
  43. }
  44. }
  45. tasks {
  46. withType<JavaCompile>().configureEach {
  47. with(options) {
  48. // Quarkus 2.0+ does not support Java 8
  49. release.set(11)
  50. }
  51. }
  52. withType<JibTask>().configureEach {
  53. dependsOn(quarkusBuild)
  54. }
  55. sourcesJar {
  56. dependsOn(quarkusGenerateCode)
  57. }
  58. }