From 992b54469266c45de7c437c762b5627d8774ddf6 Mon Sep 17 00:00:00 2001 From: Simon Levermann Date: Wed, 26 Oct 2022 13:28:58 +0200 Subject: [PATCH 1/2] Use relocation for bundled dependencies --- build.gradle | 21 ++++++++++++++++++--- pom.xml | 12 ++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 90dd078..adc38a5 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ import java.text.SimpleDateFormat plugins { id "net.nemerosa.versioning" version "2.8.2" + id "com.github.johnrengelman.shadow" version "7.1.2" } repositories { @@ -46,10 +47,24 @@ dependencies { } -jar { - from { - configurations.bundleLib.collect { it.isDirectory() ? it : zipTree(it) } +shadowJar { + archiveClassifier.set('') + manifest { + inheritFrom project.tasks.jar.manifest } + configurations = [project.configurations.bundleLib] +} + +import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation +task relocateShadowJar(type: ConfigureShadowRelocation) { + target = tasks.shadowJar + prefix = 'org.jboss.aerogear' +} + +tasks.build.dependsOn tasks.shadowJar +tasks.shadowJar.dependsOn tasks.relocateShadowJar + +jar { manifest { attributes( 'Built-By' : System.properties['user.name'], diff --git a/pom.xml b/pom.xml index c57dfe6..b5ed198 100644 --- a/pom.xml +++ b/pom.xml @@ -100,6 +100,18 @@ shade + + + + io.prometheus + org.jboss.aerogear.io.prometheus + + + javax.xml + org.jboss.aerogear.javax.xml + + + From bb659bfb12dfa5dfbf9514ad70f7d0863a8a97e2 Mon Sep 17 00:00:00 2001 From: Simon Levermann Date: Thu, 27 Oct 2022 16:58:54 +0200 Subject: [PATCH 2/2] Use shadowJar command in gradle example to build the correct jar --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d06359..892791e 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ You can choose between the tools the most convenient for you. Read further how t The project is packaged as a jar file and bundles the prometheus client libraries. ```sh -$ ./gradlew jar +$ ./gradlew shadowJar ``` builds the jar and writes it to _build/libs_.