-
Notifications
You must be signed in to change notification settings - Fork 881
/
Copy pathjava-agent.gradle
98 lines (75 loc) · 3.14 KB
/
java-agent.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
plugins {
id "com.github.johnrengelman.shadow"
}
description = 'opentelemetry-auto'
apply from: "${rootDir}/gradle/java.gradle"
apply from: "${rootDir}/gradle/version.gradle"
configurations {
shadowInclude
}
processResources {
from(zipTree(project(':instrumentation').tasks.shadowJar.archiveFile)) {
into 'auto-tooling-and-instrumentation.isolated'
rename '(^.*)\\.class$', '$1.classdata'
// Rename LICENSE file since it clashes with license dir on non-case sensitive FSs (i.e. Mac)
rename '^LICENSE$', 'LICENSE.renamed'
}
dependsOn project(':instrumentation').tasks.shadowJar
}
jar {
archiveClassifier = 'unbundled'
manifest {
attributes(
"Main-Class": "io.opentelemetry.auto.bootstrap.AgentBootstrap",
"Agent-Class": "io.opentelemetry.auto.bootstrap.AgentBootstrap",
"Premain-Class": "io.opentelemetry.auto.bootstrap.AgentBootstrap",
"Can-Redefine-Classes": true,
"Can-Retransform-Classes": true,
)
}
}
shadowJar {
configurations = [project.configurations.shadowInclude]
archiveClassifier = ''
mergeServiceFiles()
exclude '**/module-info.class'
dependencies {
exclude(dependency("org.projectlombok:lombok:$versions.lombok"))
}
// Prevents conflict with other SLF4J instances. Important for premain.
relocate 'org.slf4j', 'io.opentelemetry.auto.slf4j'
// rewrite dependencies calling Logger.getLogger
relocate 'java.util.logging.Logger', 'io.opentelemetry.auto.bootstrap.PatchLogger'
// relocate OpenTelemetry API
relocate "io.opentelemetry.OpenTelemetry", "io.opentelemetry.auto.shaded.io.opentelemetry.OpenTelemetry"
relocate "io.opentelemetry.common", "io.opentelemetry.auto.shaded.io.opentelemetry.common"
relocate "io.opentelemetry.context", "io.opentelemetry.auto.shaded.io.opentelemetry.context"
relocate "io.opentelemetry.correlationcontext", "io.opentelemetry.auto.shaded.io.opentelemetry.correlationcontext"
relocate "io.opentelemetry.internal", "io.opentelemetry.auto.shaded.io.opentelemetry.internal"
relocate "io.opentelemetry.metrics", "io.opentelemetry.auto.shaded.io.opentelemetry.metrics"
relocate "io.opentelemetry.trace", "io.opentelemetry.auto.shaded.io.opentelemetry.trace"
relocate "io.opentelemetry.contrib.auto.annotations", "io.opentelemetry.auto.shaded.io.opentelemetry.contrib.auto.annotations"
// relocate OpenTelemetry API dependency
relocate "io.grpc", "io.opentelemetry.auto.shaded.io.grpc"
}
dependencies {
testCompile project(':auto-bootstrap')
testCompile project(':utils:test-utils')
testCompile deps.testLogging
testCompile deps.guava
testCompile 'io.opentracing.contrib.dropwizard:dropwizard-opentracing:0.2.2'
shadowInclude project(path: ':auto-bootstrap')
}
tasks.withType(Test).configureEach {
// Multi-threaded logging seems to be causing deadlocks with Gradle's log capture.
// jvmArgs "-Dio.opentelemetry.auto.slf4j.simpleLogger.defaultLogLevel=debug"
// jvmArgs "-Dorg.slf4j.simpleLogger.defaultLogLevel=debug"
doFirst {
// Defining here to allow jacoco to be first on the command line.
jvmArgs "-javaagent:${shadowJar.archivePath}"
}
testLogging {
events "started"
}
dependsOn shadowJar
}