Skip to content

Commit 39e8eff

Browse files
committed
Shade wiremock
1 parent 4610cb5 commit 39e8eff

File tree

4 files changed

+68
-17
lines changed

4 files changed

+68
-17
lines changed

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ include(":testing:agent-exporter")
103103
include(":testing:agent-for-testing")
104104
include(":testing:armeria-shaded-for-testing")
105105
include(":testing:proto-shaded-for-testing")
106+
include(":testing:wiremock-shaded-for-testing")
106107
include(":testing-common")
107108
include(":testing-common:integration-tests")
108109
include(":testing-common:library-for-integration-tests")

testing-common/build.gradle.kts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ sourceSets {
1919
protoShadedDeps.file("build/extracted/shadow"),
2020
"builtBy" to ":testing:proto-shaded-for-testing:extractShadowJar"
2121
)
22+
23+
val wiremockShadedDeps = project(":testing:wiremock-shaded-for-testing")
24+
output.dir(
25+
wiremockShadedDeps.file("build/extracted/shadow"),
26+
"builtBy" to ":testing:wiremock-shaded-for-testing:extractShadowJar"
27+
)
2228
}
2329
}
2430

@@ -54,13 +60,10 @@ dependencies {
5460
api("org.mockito:mockito-core")
5561
api("org.slf4j:slf4j-api")
5662

57-
// used to record LLM responses in gen AI tests
58-
api("com.github.tomakehurst:wiremock-jre8:2.35.2")
59-
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2")
60-
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.18.2")
61-
6263
compileOnly(project(":testing:armeria-shaded-for-testing", configuration = "shadow"))
6364
compileOnly(project(":testing:proto-shaded-for-testing", configuration = "shadow"))
65+
// used to record LLM responses in gen AI tests
66+
compileOnly(project(":testing:wiremock-shaded-for-testing", configuration = "shadow"))
6467
compileOnly(project(":javaagent-bootstrap"))
6568

6669
compileOnly("com.google.auto.value:auto-value-annotations")
@@ -93,4 +96,9 @@ tasks {
9396
javadoc {
9497
enabled = false
9598
}
99+
100+
jar {
101+
// When there are duplicates between multiple shaded dependencies, just ignore them.
102+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
103+
}
96104
}

testing-common/src/main/java/io/opentelemetry/instrumentation/testing/recording/YamlFileMappingsSource.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@
88
import static com.github.tomakehurst.wiremock.common.AbstractFileSource.byFileExtension;
99
import static com.github.tomakehurst.wiremock.common.Exceptions.throwUnchecked;
1010

11-
import com.fasterxml.jackson.annotation.JsonInclude.Include;
12-
import com.fasterxml.jackson.core.JsonGenerator;
13-
import com.fasterxml.jackson.core.JsonParser;
14-
import com.fasterxml.jackson.core.JsonProcessingException;
15-
import com.fasterxml.jackson.databind.DeserializationFeature;
16-
import com.fasterxml.jackson.databind.ObjectMapper;
17-
import com.fasterxml.jackson.databind.ObjectWriter;
18-
import com.fasterxml.jackson.databind.SerializationFeature;
19-
import com.fasterxml.jackson.databind.cfg.JsonNodeFeature;
20-
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
21-
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
22-
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
2311
import com.github.tomakehurst.wiremock.common.FileSource;
2412
import com.github.tomakehurst.wiremock.common.Json;
2513
import com.github.tomakehurst.wiremock.common.JsonException;
@@ -29,6 +17,18 @@
2917
import com.github.tomakehurst.wiremock.standalone.MappingsSource;
3018
import com.github.tomakehurst.wiremock.stubbing.StubMapping;
3119
import com.github.tomakehurst.wiremock.stubbing.StubMappings;
20+
import io.opentelemetry.testing.internal.jackson.annotation.JsonInclude.Include;
21+
import io.opentelemetry.testing.internal.jackson.core.JsonGenerator;
22+
import io.opentelemetry.testing.internal.jackson.core.JsonParser;
23+
import io.opentelemetry.testing.internal.jackson.core.JsonProcessingException;
24+
import io.opentelemetry.testing.internal.jackson.databind.DeserializationFeature;
25+
import io.opentelemetry.testing.internal.jackson.databind.ObjectMapper;
26+
import io.opentelemetry.testing.internal.jackson.databind.ObjectWriter;
27+
import io.opentelemetry.testing.internal.jackson.databind.SerializationFeature;
28+
import io.opentelemetry.testing.internal.jackson.databind.cfg.JsonNodeFeature;
29+
import io.opentelemetry.testing.internal.jackson.dataformat.yaml.YAMLGenerator;
30+
import io.opentelemetry.testing.internal.jackson.dataformat.yaml.YAMLMapper;
31+
import io.opentelemetry.testing.internal.jackson.datatype.jsr310.JavaTimeModule;
3232
import java.io.IOException;
3333
import java.lang.reflect.Method;
3434
import java.nio.file.Files;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
plugins {
2+
id("com.gradleup.shadow")
3+
id("otel.java-conventions")
4+
}
5+
6+
dependencies {
7+
implementation("com.github.tomakehurst:wiremock-jre8:2.35.2")
8+
implementation("com.google.errorprone:error_prone_annotations")
9+
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.18.2")
10+
}
11+
12+
tasks {
13+
shadowJar {
14+
dependencies {
15+
exclude(dependency("org.slf4j:slf4j-api"))
16+
exclude(dependency("org.junit.jupiter:junit-jupiter-api"))
17+
exclude(dependency("org.junit.platform:junit-platform-commons"))
18+
// Exclude dependencies bundled during Armeria shading
19+
exclude(dependency("com.fasterxml.jackson.core:jackson-annotations"))
20+
exclude(dependency("com.fasterxml.jackson.core:jackson-core"))
21+
exclude(dependency("com.fasterxml.jackson.core:jackson-databind"))
22+
}
23+
24+
// Ensures tests are not affected by wiremock dependencies. Wiremock itself is
25+
// safe with its original name.
26+
relocate("org.eclipse.jetty", "io.opentelemetry.testing.internal.jetty")
27+
relocate("com.fasterxml.jackson", "io.opentelemetry.testing.internal.jackson")
28+
29+
mergeServiceFiles()
30+
}
31+
32+
val extractShadowJar by registering(Copy::class) {
33+
dependsOn(shadowJar)
34+
// there's both "LICENSE" file and "license" and without excluding one of these build fails on case insensitive file systems
35+
// there's a LICENSE.txt file that has the same contents anyway, so we're not losing anything excluding that
36+
from(zipTree(shadowJar.get().archiveFile)) {
37+
exclude("META-INF/LICENSE")
38+
}
39+
into("build/extracted/shadow")
40+
includeEmptyDirs = false
41+
}
42+
}

0 commit comments

Comments
 (0)