forked from open-telemetry/opentelemetry-java
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
131 lines (112 loc) · 4.04 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
131 lines (112 loc) · 4.04 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
plugins {
id("otel.java-conventions")
id("otel.publish-conventions")
id("otel.animalsniffer-conventions")
}
description = "OpenTelemetry Exporter Common"
otelJava.moduleName.set("io.opentelemetry.exporter.internal")
otelJava.osgiOptionalPackages.set(listOf("com.google.common.io", "io.opentelemetry.api.incubator.config", "io.opentelemetry.sdk.autoconfigure.spi"))
// sun.misc, io.grpc, and org.jspecify are not OSGi bundles and have no package versioning; must use unversioned optional.
otelJava.osgiUnversionedOptionalPackages.set(listOf("sun.misc", "io.grpc", "org.jspecify.annotations"))
// This bundle's exporters load sender implementations via SPI.
otelJava.osgiServiceLoaderRequires.set(listOf(
"io.opentelemetry.sdk.common.export.GrpcSenderProvider",
"io.opentelemetry.sdk.common.export.HttpSenderProvider"
))
java {
sourceSets {
create("java9") {
java {
srcDir("src/main/java9")
}
// Make java9 source set depend on main source set
// since VarHandleStringEncoder implements StringEncoder from the main source set
compileClasspath += sourceSets.main.get().output + sourceSets.main.get().compileClasspath
}
}
}
// Configure java9 compilation to see main source classes
sourceSets.named("java9") {
compileClasspath += sourceSets.main.get().output
}
tasks.named<JavaCompile>("compileJava9Java") {
options.release.set(9)
}
tasks.named<Jar>("jar") {
manifest {
attributes["Multi-Release"] = "true"
}
from(sourceSets.named("java9").get().output) {
into("META-INF/versions/9")
}
}
// Configure test to include java9 classes when running on Java 9+
// so that StringEncoderHolder.createUnsafeEncoder() can instantiate the Java 9 version
val javaVersion = JavaVersion.current()
if (javaVersion >= JavaVersion.VERSION_1_9) {
sourceSets.named("test") {
runtimeClasspath += sourceSets.named("java9").get().output
}
}
val versions = project.property("versions") as Map<*, *>
dependencies {
api(project(":api:all"))
compileOnly(project(":sdk-extensions:autoconfigure-spi"))
compileOnly(project(":api:incubator"))
compileOnly(project(":sdk:common"))
compileOnly(project(":exporters:common:compile-stub"))
compileOnly("org.codehaus.mojo:animal-sniffer-annotations")
annotationProcessor("com.google.auto.value:auto-value")
// sun.misc.Unsafe from the JDK isn't found by the compiler, we provide our own trimmed down
// version that we can compile against.
compileOnly("io.grpc:grpc-stub")
testImplementation(project(":sdk:common"))
testImplementation(project(":sdk:testing"))
testImplementation("com.google.protobuf:protobuf-java-util")
testImplementation("com.linecorp.armeria:armeria-junit5")
testImplementation("com.google.api.grpc:proto-google-common-protos")
testImplementation("io.grpc:grpc-testing")
testImplementation("edu.berkeley.cs.jqf:jqf-fuzz")
testRuntimeOnly("io.grpc:grpc-netty-shaded")
}
val testJavaVersion = project.findProperty("testJavaVersion") as String?
testing {
suites {
register<JvmTestSuite>("testSenderProvider") {
dependencies {
implementation(project(":exporters:sender:jdk"))
implementation(project(":exporters:sender:okhttp"))
implementation(project(":exporters:sender:grpc-managed-channel"))
implementation(project(":sdk:common"))
}
targets {
all {
testTask {
enabled = !testJavaVersion.equals("8")
}
}
}
}
}
suites {
register<JvmTestSuite>("testWithoutUnsafe") {}
}
}
tasks {
check {
dependsOn(testing.suites)
}
withType<Test> {
// Allow VarHandle access to String internals
// generally users won't do this and so won't get the VarHandle implementation
// but the Java agent is able to automatically open these modules
// (see ModuleOpener.java in that repository)
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") // needed for Java 8
}
}
afterEvaluate {
tasks.named<JavaCompile>("compileTestSenderProviderJava") {
options.release.set(11)
}
}