Skip to content

Commit

Permalink
feat: support creating shaded jars (#333)
Browse files Browse the repository at this point in the history
Some applications that load multiple JDBC drivers may run into dependency
conflicts if other JDBC drivers use the same dependencies but different
versions. This problem can be mitigated by creating a jar with shaded
dependencies. This change adds a Maven profile for creating shaded jars.

Fixes #316
  • Loading branch information
olavloite committed Jan 31, 2021
1 parent 712689d commit 8b4e50d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .readme-partials.yaml
Expand Up @@ -23,3 +23,14 @@ custom_content: |
}
}
```
### Creating a Shaded Jar
A jar with all dependencies included is automatically generated when you execute `mvn package`.
The dependencies in this jar are not shaded. To create a jar with shaded dependencies you must
activate the `shade` profile like this:
```
mvn package -Pshade
```
44 changes: 44 additions & 0 deletions pom.xml
Expand Up @@ -309,6 +309,50 @@
</plugins>
</pluginManagement>
</build>

<profiles>
<profile>
<id>shade</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<relocations>
<relocation>
<pattern>com</pattern>
<shadedPattern>com.google.cloud.spanner.jdbc.shaded.com</shadedPattern>
<excludes>
<exclude>com.google.cloud.spanner.**</exclude>
</excludes>
</relocation>
<relocation>
<pattern>android</pattern>
<shadedPattern>com.google.cloud.spanner.jdbc.shaded.android</shadedPattern>
</relocation>
<relocation>
<pattern>io</pattern>
<shadedPattern>com.google.cloud.spanner.jdbc.shaded.io</shadedPattern>
<excludes>
<exclude>io.grpc.netty.shaded.**</exclude>
</excludes>
</relocation>
<relocation>
<pattern>org</pattern>
<shadedPattern>com.google.cloud.spanner.jdbc.shaded.org</shadedPattern>
<excludes>
<exclude>org.conscrypt.**</exclude>
</excludes>
</relocation>
</relocations>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<reporting>
<plugins>
<plugin>
Expand Down

0 comments on commit 8b4e50d

Please sign in to comment.