Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use relocation for bundled dependencies #146

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_.
Expand Down
21 changes: 18 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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'],
Expand Down
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>io.prometheus</pattern>
<shadedPattern>org.jboss.aerogear.io.prometheus</shadedPattern>
</relocation>
<relocation>
<pattern>javax.xml</pattern>
<shadedPattern>org.jboss.aerogear.javax.xml</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
Expand Down