|
| 1 | +import groovy.lang.Closure |
| 2 | + |
| 3 | +plugins { |
| 4 | + `java-library` |
| 5 | + id("com.gradleup.shadow") |
| 6 | + id("me.champeau.jmh") |
| 7 | +} |
| 8 | + |
| 9 | +description = "dd-trace-ot" |
| 10 | + |
| 11 | +apply(from = rootDir.resolve("gradle/java.gradle")) |
| 12 | +apply(from = rootDir.resolve("gradle/publish.gradle")) |
| 13 | + |
| 14 | +// TODO raise these when equals() and hashCode() are excluded |
| 15 | +val minimumBranchCoverage by extra(0.5) |
| 16 | +val minimumInstructionCoverage by extra(0.5) |
| 17 | + |
| 18 | +val excludedClassesCoverage by extra( |
| 19 | + listOf( |
| 20 | + // This is mainly equals() and hashCode() |
| 21 | + "datadog.opentracing.OTScopeManager.OTScope", |
| 22 | + "datadog.opentracing.OTScopeManager.FakeScope", |
| 23 | + "datadog.opentracing.OTSpan", |
| 24 | + "datadog.opentracing.OTSpanContext", |
| 25 | + "datadog.opentracing.CustomScopeManagerWrapper.CustomScopeState", |
| 26 | + // The builder is generated |
| 27 | + "datadog.opentracing.DDTracer.DDTracerBuilder" |
| 28 | + ) |
| 29 | +) |
| 30 | + |
| 31 | +// Helper extensions for custom methods from Groovy DSL |
| 32 | +fun addTestSuite(name: String) { |
| 33 | + (project.extra["addTestSuite"] as? Closure<*>)?.call(name) |
| 34 | +} |
| 35 | + |
| 36 | +addTestSuite("ot31CompatibilityTest") |
| 37 | +addTestSuite("ot33CompatibilityTest") |
| 38 | + |
| 39 | +dependencies { |
| 40 | + annotationProcessor(libs.autoservice.processor) |
| 41 | + compileOnly(libs.autoservice.annotation) |
| 42 | + |
| 43 | + modules { |
| 44 | + module("com.squareup.okio:okio") { |
| 45 | + replacedBy("com.datadoghq.okio:okio") // embed our patched fork |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + api(project(":dd-trace-api")) |
| 50 | + implementation(project(":dd-trace-core")) { |
| 51 | + // why all communication pulls in remote config is beyond me... |
| 52 | + exclude(group = "com.datadoghq", module = "remote-config-core") |
| 53 | + } |
| 54 | + // exception replay |
| 55 | + implementation(project(":dd-java-agent:agent-debugger:debugger-bootstrap")) |
| 56 | + |
| 57 | + // OpenTracing |
| 58 | + api("io.opentracing:opentracing-api:0.32.0") |
| 59 | + api("io.opentracing:opentracing-noop:0.32.0") |
| 60 | + api("io.opentracing:opentracing-util:0.32.0") |
| 61 | + api("io.opentracing.contrib:opentracing-tracerresolver:0.1.6") |
| 62 | + |
| 63 | + api(libs.slf4j) |
| 64 | + api(libs.jnr.unixsocket) |
| 65 | + |
| 66 | + implementation(project(":dd-trace-ot:correlation-id-injection")) |
| 67 | + |
| 68 | + testImplementation(project(":dd-java-agent:testing")) |
| 69 | + |
| 70 | + // Kotlin accessors not generated if not coming from plugin |
| 71 | + add("ot33CompatibilityTestImplementation", "io.opentracing:opentracing-api") { |
| 72 | + version { |
| 73 | + strictly("0.33.0") |
| 74 | + } |
| 75 | + } |
| 76 | + add("ot33CompatibilityTestImplementation", "io.opentracing:opentracing-util") { |
| 77 | + version { |
| 78 | + strictly("0.33.0") |
| 79 | + } |
| 80 | + } |
| 81 | + add("ot33CompatibilityTestImplementation", "io.opentracing:opentracing-noop") { |
| 82 | + version { |
| 83 | + strictly("0.33.0") |
| 84 | + } |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +// gradle can't downgrade the opentracing dependencies with `strictly` |
| 89 | +configurations.matching { it.name.startsWith("ot31") }.all { |
| 90 | + resolutionStrategy { |
| 91 | + force("io.opentracing:opentracing-api:0.31.0") |
| 92 | + force("io.opentracing:opentracing-util:0.31.0") |
| 93 | + force("io.opentracing:opentracing-noop:0.31.0") |
| 94 | + } |
| 95 | +} |
| 96 | + |
| 97 | +tasks.test { |
| 98 | + finalizedBy( |
| 99 | + tasks.named("ot31CompatibilityTest"), |
| 100 | + tasks.named("ot33CompatibilityTest"), |
| 101 | + ) |
| 102 | +} |
| 103 | + |
| 104 | +tasks.jar { |
| 105 | + destinationDirectory = layout.buildDirectory.dir("libs-unbundled") |
| 106 | + archiveClassifier = "unbundled" |
| 107 | +} |
| 108 | + |
| 109 | +// shadowJar configuration |
| 110 | + |
| 111 | +// The shadowJar block configures the shadow JAR packaging |
| 112 | +// and dependency relocation/exclusion rules. |
| 113 | +tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") { |
| 114 | + archiveClassifier = "" |
| 115 | + |
| 116 | + dependencies { |
| 117 | + // direct dependencies |
| 118 | + exclude(project(":dd-trace-api")) |
| 119 | + exclude(dependency("io.opentracing:")) |
| 120 | + exclude(dependency("io.opentracing.contrib:")) |
| 121 | + exclude(dependency("org.slf4j:")) |
| 122 | + exclude(dependency("com.github.jnr:")) |
| 123 | + } |
| 124 | + |
| 125 | + relocate("com.", "ddtrot.com.") { |
| 126 | + // leave our PatchInit class shaded even though its not used in this deployment |
| 127 | + // unfortunately the shadow plugin doesn't let us completely remove this class |
| 128 | + exclude("%regex[com/kenai/jffi/(?!PatchInit)[^/]*]") |
| 129 | + } |
| 130 | + relocate("dogstatsd/", "ddtrot/dogstatsd/") |
| 131 | + relocate("okhttp3.", "ddtrot.okhttp3.") |
| 132 | + relocate("okio.", "ddtrot.okio.") |
| 133 | + relocate("org.", "ddtrot.org.") { |
| 134 | + exclude("org.slf4j.*") |
| 135 | + } |
| 136 | + relocate("datadog.", "ddtrot.dd.") { |
| 137 | + exclude("datadog.opentracing.*") |
| 138 | + exclude("datadog.opentracing.resolver.*") |
| 139 | + exclude("%regex[datadog/trace/api/(?!Functions|Endpoint)[^/]*]") |
| 140 | + exclude("datadog.trace.api.config.*") |
| 141 | + exclude("datadog.trace.api.experimental.*") |
| 142 | + exclude("datadog.trace.api.interceptor.*") |
| 143 | + exclude("datadog.trace.api.internal.*") |
| 144 | + exclude("datadog.trace.api.internal.util.*") |
| 145 | + exclude("datadog.trace.api.profiling.*") |
| 146 | + exclude("datadog.trace.api.sampling.*") |
| 147 | + exclude("datadog.trace.context.*") |
| 148 | + } |
| 149 | + |
| 150 | + duplicatesStrategy = DuplicatesStrategy.FAIL |
| 151 | + |
| 152 | + // Remove some cruft from the final jar. |
| 153 | + // These patterns should NOT include **/META-INF/maven/**/pom.properties, which is |
| 154 | + // used to report our own dependencies. |
| 155 | + exclude("**/META-INF/maven/**/pom.xml") |
| 156 | + exclude("META-INF/proguard/") |
| 157 | + exclude("/META-INF/*.kotlin_module") |
| 158 | +} |
| 159 | + |
| 160 | +jmh { |
| 161 | + // include = [".*URLAsResourceNameBenchmark"] |
| 162 | + // include = ['some regular expression'] // include pattern (regular expression) for benchmarks to be executed |
| 163 | + // exclude = ['some regular expression'] // exclude pattern (regular expression) for benchmarks to be executed |
| 164 | + iterations = 1 // Number of measurement iterations to do. |
| 165 | + benchmarkMode = listOf("thrpt", "avgt", "ss") |
| 166 | + // Benchmark mode. Available modes are: [Throughput/thrpt, AverageTime/avgt, SampleTime/sample, SingleShotTime/ss, All/all] |
| 167 | + batchSize = 1 |
| 168 | + // Batch size: number of benchmark method calls per operation. (some benchmark modes can ignore this setting) |
| 169 | + fork = 1 // How many times to forks a single benchmark. Use 0 to disable forking altogether |
| 170 | + failOnError = false // Should JMH fail immediately if any benchmark had experienced the unrecoverable error? |
| 171 | + forceGC = false // Should JMH force GC between iterations? |
| 172 | + // jvm = 'myjvm' // Custom JVM to use when forking. |
| 173 | + // jvmArgs = ['Custom JVM args to use when forking.'] |
| 174 | + // jvmArgsAppend = ['Custom JVM args to use when forking (append these)'] |
| 175 | + // jvmArgsPrepend =[ 'Custom JVM args to use when forking (prepend these)'] |
| 176 | + // humanOutputFile = project.file("${project.buildDir}/reports/jmh/human.txt") // human-readable output file |
| 177 | + // resultsFile = project.file("${project.buildDir}/reports/jmh/results.txt") // results file |
| 178 | + // operationsPerInvocation = 10 // Operations per invocation. |
| 179 | + // benchmarkParameters = [:] // Benchmark parameters. |
| 180 | + // profilers = ['stack'] // Use profilers to collect additional data. Supported profilers: [cl, comp, gc, stack, perf, perfnorm, perfasm, xperf, xperfasm, hs_cl, hs_comp, hs_gc, hs_rt, hs_thr] |
| 181 | + timeOnIteration = "1s" // Time to spend at each measurement iteration. |
| 182 | + // resultFormat = 'CSV' // Result format type (one of CSV, JSON, NONE, SCSV, TEXT) |
| 183 | + // synchronizeIterations = false // Synchronize iterations? |
| 184 | + // threads = 2 // Number of worker threads to run with. |
| 185 | + // threadGroups = [2,3,4] //Override thread group distribution for asymmetric benchmarks. |
| 186 | + // timeout = '1s' // Timeout for benchmark iteration. |
| 187 | + timeUnit = "us" // Output time unit. Available time units are: [m, s, ms, us, ns]. |
| 188 | + // verbosity = 'NORMAL' // Verbosity mode. Available modes are: [SILENT, NORMAL, EXTRA] |
| 189 | + warmup = "2s" // Time to spend at each warmup iteration. |
| 190 | + // warmupBatchSize = 10 // Warmup batch size: number of benchmark method calls per operation. |
| 191 | + warmupForks = 1 // How many warmup forks to make for a single benchmark. 0 to disable warmup forks. |
| 192 | + warmupIterations = 1 // Number of warmup iterations to do. |
| 193 | + // warmupMode = 'INDI' // Warmup mode for warming up selected benchmarks. Warmup modes are: [INDI, BULK, BULK_INDI]. |
| 194 | + // warmupBenchmarks = ['.*Warmup'] // Warmup benchmarks to include in the run in addition to already selected. JMH will not measure these benchmarks, but only use them for the warmup. |
| 195 | + |
| 196 | + // zip64 = true // Use ZIP64 format for bigger archives |
| 197 | + jmhVersion = "1.23" // Specifies JMH version |
| 198 | + // includeTests = true // Allows to include test sources into generate JMH jar, i.e. use it when benchmarks depend on the test classes. |
| 199 | + // duplicateClassesStrategy = 'warn' // Strategy to apply when encountring duplicate classes during creation of the fat jar (i.e. while executing jmhJar task) |
| 200 | +} |
0 commit comments