@@ -10,3 +10,56 @@ description = "JMX metrics scrapper"
1010otelJava.moduleName.set(" io.opentelemetry.contrib.jmxscrapper" )
1111
1212application.mainClass.set(" io.opentelemetry.contrib.jmxscrapper.JmxMetrics" )
13+
14+ dependencies {
15+ implementation(" io.opentelemetry:opentelemetry-api" )
16+ implementation(" io.opentelemetry:opentelemetry-sdk" )
17+ implementation(" io.opentelemetry:opentelemetry-sdk-metrics" )
18+ implementation(" io.opentelemetry:opentelemetry-sdk-extension-autoconfigure" )
19+ implementation(" io.opentelemetry:opentelemetry-sdk-testing" )
20+
21+ implementation(" io.opentelemetry.instrumentation:opentelemetry-jmx-metrics" )
22+
23+ }
24+
25+
26+ tasks {
27+ shadowJar {
28+ mergeServiceFiles()
29+
30+ manifest {
31+ attributes[" Implementation-Version" ] = project.version
32+ }
33+ // This should always be standalone, so remove "-all" to prevent unnecessary artifact.
34+ archiveClassifier.set(" " )
35+ }
36+
37+ jar {
38+ archiveClassifier.set(" noshadow" )
39+ }
40+
41+ withType<Test >().configureEach {
42+ dependsOn(shadowJar)
43+ systemProperty(" shadow.jar.path" , shadowJar.get().archiveFile.get().asFile.absolutePath)
44+ systemProperty(" gradle.project.version" , " ${project.version} " )
45+ }
46+
47+ // Because we reconfigure publishing to only include the shadow jar, the Gradle metadata is not correct.
48+ // Since we are fully bundled and have no dependencies, Gradle metadata wouldn't provide any advantage over
49+ // the POM anyways so in practice we shouldn't be losing anything.
50+ withType<GenerateModuleMetadata >().configureEach {
51+ enabled = false
52+ }
53+ }
54+
55+ // Don't publish non-shadowed jar (shadowJar is in shadowRuntimeElements)
56+ with (components[" java" ] as AdhocComponentWithVariants ) {
57+ configurations.forEach {
58+ withVariantsFromConfiguration(configurations[" apiElements" ]) {
59+ skip()
60+ }
61+ withVariantsFromConfiguration(configurations[" runtimeElements" ]) {
62+ skip()
63+ }
64+ }
65+ }
0 commit comments