build.gradle.kts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
  2. plugins {
  3. id("com.github.johnrengelman.shadow")
  4. id("otel.java-conventions")
  5. }
  6. description = "opentelemetry-api shaded for internal javaagent usage"
  7. group = "io.opentelemetry.javaagent"
  8. val latestDeps by configurations.creating {
  9. isCanBeResolved = true
  10. isCanBeConsumed = false
  11. }
  12. val v1_10Deps by configurations.creating {
  13. isCanBeResolved = true
  14. isCanBeConsumed = false
  15. // exclude the bom added by dependencyManagement
  16. exclude("io.opentelemetry", "opentelemetry-bom")
  17. }
  18. val v1_15Deps by configurations.creating {
  19. isCanBeResolved = true
  20. isCanBeConsumed = false
  21. // exclude the bom added by dependencyManagement
  22. exclude("io.opentelemetry", "opentelemetry-bom")
  23. }
  24. val v1_27Deps by configurations.creating {
  25. isCanBeResolved = true
  26. isCanBeConsumed = false
  27. // exclude the bom added by dependencyManagement
  28. exclude("io.opentelemetry", "opentelemetry-bom")
  29. }
  30. val v1_31Deps by configurations.creating {
  31. isCanBeResolved = true
  32. isCanBeConsumed = false
  33. // exclude the bom added by dependencyManagement
  34. exclude("io.opentelemetry", "opentelemetry-bom")
  35. exclude("io.opentelemetry", "opentelemetry-bom-alpha")
  36. }
  37. val v1_32Deps by configurations.creating {
  38. isCanBeResolved = true
  39. isCanBeConsumed = false
  40. // exclude the bom added by dependencyManagement
  41. exclude("io.opentelemetry", "opentelemetry-bom")
  42. exclude("io.opentelemetry", "opentelemetry-bom-alpha")
  43. }
  44. val v1_37Deps by configurations.creating {
  45. isCanBeResolved = true
  46. isCanBeConsumed = false
  47. // exclude the bom added by dependencyManagement
  48. exclude("io.opentelemetry", "opentelemetry-bom")
  49. exclude("io.opentelemetry", "opentelemetry-bom-alpha")
  50. }
  51. val v1_38Deps by configurations.creating {
  52. isCanBeResolved = true
  53. isCanBeConsumed = false
  54. // exclude the bom added by dependencyManagement
  55. exclude("io.opentelemetry", "opentelemetry-bom")
  56. exclude("io.opentelemetry", "opentelemetry-bom-alpha")
  57. }
  58. // configuration for publishing the shadowed artifact
  59. val v1_10 by configurations.creating {
  60. isCanBeConsumed = true
  61. isCanBeResolved = false
  62. }
  63. val v1_15 by configurations.creating {
  64. isCanBeConsumed = true
  65. isCanBeResolved = false
  66. }
  67. val v1_27 by configurations.creating {
  68. isCanBeConsumed = true
  69. isCanBeResolved = false
  70. }
  71. val v1_31 by configurations.creating {
  72. isCanBeConsumed = true
  73. isCanBeResolved = false
  74. }
  75. val v1_32 by configurations.creating {
  76. isCanBeConsumed = true
  77. isCanBeResolved = false
  78. }
  79. val v1_37 by configurations.creating {
  80. isCanBeConsumed = true
  81. isCanBeResolved = false
  82. }
  83. val v1_38 by configurations.creating {
  84. isCanBeConsumed = true
  85. isCanBeResolved = false
  86. }
  87. dependencies {
  88. latestDeps("io.opentelemetry:opentelemetry-api")
  89. listOf("opentelemetry-api", "opentelemetry-context").forEach {
  90. v1_10Deps("io.opentelemetry:$it") {
  91. version {
  92. strictly("1.10.0")
  93. }
  94. }
  95. v1_15Deps("io.opentelemetry:$it") {
  96. version {
  97. strictly("1.15.0")
  98. }
  99. }
  100. v1_27Deps("io.opentelemetry:$it") {
  101. version {
  102. strictly("1.27.0")
  103. }
  104. }
  105. v1_31Deps("io.opentelemetry:$it") {
  106. version {
  107. strictly("1.31.0")
  108. }
  109. }
  110. v1_32Deps("io.opentelemetry:$it") {
  111. version {
  112. strictly("1.32.0")
  113. }
  114. }
  115. }
  116. listOf("opentelemetry-extension-incubator").forEach {
  117. v1_31Deps("io.opentelemetry:$it") {
  118. version {
  119. strictly("1.31.0-alpha")
  120. }
  121. }
  122. v1_32Deps("io.opentelemetry:$it") {
  123. version {
  124. strictly("1.32.0-alpha")
  125. }
  126. }
  127. }
  128. listOf("opentelemetry-api-incubator").forEach {
  129. v1_37Deps("io.opentelemetry:$it") {
  130. version {
  131. strictly("1.37.0-alpha")
  132. }
  133. }
  134. v1_38Deps("io.opentelemetry:$it") {
  135. version {
  136. strictly("1.38.0-alpha")
  137. }
  138. }
  139. }
  140. }
  141. // OpenTelemetry API shaded so that it can be used in instrumentation of OpenTelemetry API itself,
  142. // and then its usage can be unshaded after OpenTelemetry API is shaded
  143. // (see more explanation in opentelemetry-api-1.0.gradle)
  144. tasks {
  145. withType<ShadowJar>().configureEach {
  146. relocate("io.opentelemetry", "application.io.opentelemetry")
  147. }
  148. shadowJar {
  149. configurations = listOf(latestDeps)
  150. }
  151. val v1_10Shadow by registering(ShadowJar::class) {
  152. configurations = listOf(v1_10Deps)
  153. archiveClassifier.set("v1_10")
  154. }
  155. val v1_15Shadow by registering(ShadowJar::class) {
  156. configurations = listOf(v1_15Deps)
  157. archiveClassifier.set("v1_15")
  158. }
  159. val v1_27Shadow by registering(ShadowJar::class) {
  160. configurations = listOf(v1_27Deps)
  161. archiveClassifier.set("v1_27")
  162. }
  163. val v1_31Shadow by registering(ShadowJar::class) {
  164. configurations = listOf(v1_31Deps)
  165. archiveClassifier.set("v1_31")
  166. }
  167. val v1_32Shadow by registering(ShadowJar::class) {
  168. configurations = listOf(v1_32Deps)
  169. archiveClassifier.set("v1_32")
  170. }
  171. val v1_37Shadow by registering(ShadowJar::class) {
  172. configurations = listOf(v1_37Deps)
  173. archiveClassifier.set("v1_37")
  174. }
  175. val v1_38Shadow by registering(ShadowJar::class) {
  176. configurations = listOf(v1_38Deps)
  177. archiveClassifier.set("v1_38")
  178. }
  179. artifacts {
  180. add(v1_10.name, v1_10Shadow)
  181. add(v1_15.name, v1_15Shadow)
  182. add(v1_27.name, v1_27Shadow)
  183. add(v1_31.name, v1_31Shadow)
  184. add(v1_32.name, v1_32Shadow)
  185. add(v1_37.name, v1_37Shadow)
  186. add(v1_38.name, v1_38Shadow)
  187. }
  188. }