dd-java-agent.gradle 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. plugins {
  2. id "com.github.johnrengelman.shadow" version "2.0.1"
  3. }
  4. description = 'dd-java-agent'
  5. apply from: "${rootDir}/gradle/java.gradle"
  6. apply from: "${rootDir}/gradle/publish.gradle"
  7. apply from: "${rootDir}/gradle/jacoco.gradle"
  8. jacocoTestReport.dependsOn ':dd-java-agent-ittests:test'
  9. whitelistedInstructionClasses += whitelistedBranchClasses += [
  10. 'com.datadoghq.agent.*',
  11. 'com.datadoghq.agent.integration.*',
  12. 'io.opentracing.contrib.*',
  13. 'dd.opentracing.contrib.*',
  14. ]
  15. dependencies {
  16. compile project(':dd-trace')
  17. compile project(':dd-java-agent:tooling')
  18. compile project(':dd-trace-annotations')
  19. compile(project(':dd-java-agent:integrations:apache-httpclient-4.3')) {
  20. transitive = false
  21. }
  22. compile(project(':dd-java-agent:integrations:aws-sdk')) {
  23. transitive = false
  24. }
  25. compile(project(':dd-java-agent:integrations:datastax-cassandra-3.2')) {
  26. transitive = false
  27. }
  28. compile(project(':dd-java-agent:integrations:jms-1')) {
  29. transitive = false
  30. }
  31. compile(project(':dd-java-agent:integrations:jms-2')) {
  32. transitive = false
  33. }
  34. compile(project(':dd-java-agent:integrations:mongo-3.1')) {
  35. transitive = false
  36. }
  37. compile(project(':dd-java-agent:integrations:mongo-async-3.3')) {
  38. transitive = false
  39. }
  40. compile(project(':dd-java-agent:integrations:okhttp-3')) {
  41. transitive = false
  42. }
  43. compile(project(':dd-java-agent:integrations:servlet-2')) {
  44. transitive = false
  45. }
  46. compile(project(':dd-java-agent:integrations:servlet-3')) {
  47. transitive = false
  48. }
  49. compile(project(':dd-java-agent:integrations:spring-web')) {
  50. transitive = false
  51. }
  52. compile deps.bytebuddy
  53. compile deps.autoservice
  54. compile deps.slf4j
  55. compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
  56. // ^ Generally a bad idea for libraries, but we're shadowing.
  57. testCompile deps.opentracingMock
  58. testCompile(project(path: ':dd-java-agent:integrations:helpers')) {
  59. transitive = false
  60. }
  61. }
  62. project(':dd-java-agent:integrations:helpers').afterEvaluate { helperProject ->
  63. project.processResources {
  64. from(helperProject.tasks.shadowJar)
  65. rename {
  66. it.startsWith("helpers") && it.endsWith(".jar") ?
  67. "helpers.jar.zip" :
  68. it
  69. }
  70. }
  71. project.processResources.dependsOn helperProject.tasks.shadowJar
  72. }
  73. jar {
  74. classifier = 'unbundled'
  75. manifest {
  76. attributes(
  77. "Main-Class": "com.datadoghq.agent.DDJavaAgentInfo",
  78. // I don't think we want to define this since we can't really load after startup:
  79. //"Agent-Class": "com.datadoghq.trace.agent.TracingAgent",
  80. "Premain-Class": "com.datadoghq.agent.TracingAgent",
  81. "Can-Redefine-Classes": true,
  82. "Can-Retransform-Classes": true,
  83. )
  84. }
  85. }
  86. shadowJar {
  87. classifier null
  88. mergeServiceFiles() // This triggers shadow to also apply the relocate rules below to the service files.
  89. relocate 'org.slf4j', 'dd.slf4j' // Prevents conflict with other SLF4J instances. Important for premain.
  90. if (!project.hasProperty("disableShadowRelocate") || !disableShadowRelocate) {
  91. // These need to be relocated to prevent conflicts in case the regular dd-trace is already on the classpath.
  92. relocate('com.datadoghq.trace', 'com.datadoghq.agent.tracer') {
  93. // We want to ensure to not miss if a user is using the annotation.
  94. exclude 'com.datadoghq.trace.Trace'
  95. }
  96. relocate 'io.opentracing.contrib', 'dd.opentracing.contrib'
  97. relocate 'org.yaml', 'dd.deps.org.yaml'
  98. relocate 'org.msgpack', 'dd.deps.org.msgpack'
  99. relocate 'com.fasterxml', 'dd.deps.com.fasterxml'
  100. relocate 'net.bytebuddy', 'dd.deps.net.bytebuddy'
  101. relocate('com.google', 'dd.deps.com.google') {
  102. // This is used in the Cassandra Cluster.connectAsync signature so we can't relocate it. :fingers_crossed:
  103. exclude 'com.google.common.util.concurrent.ListenableFuture'
  104. }
  105. }
  106. dependencies {
  107. exclude(dependency('org.projectlombok:lombok:1.16.18'))
  108. }
  109. }
  110. // We don't want bundled dependencies to show up in the pom.
  111. modifyPom {
  112. dependencies.removeAll { true }
  113. }