Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 8b4e50d

Browse files
authored
feat: support creating shaded jars (#333)
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
1 parent 712689d commit 8b4e50d

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

.readme-partials.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,14 @@ custom_content: |
2323
}
2424
}
2525
```
26+
27+
### Creating a Shaded Jar
28+
29+
A jar with all dependencies included is automatically generated when you execute `mvn package`.
30+
The dependencies in this jar are not shaded. To create a jar with shaded dependencies you must
31+
activate the `shade` profile like this:
32+
33+
```
34+
mvn package -Pshade
35+
```
36+

pom.xml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,50 @@
309309
</plugins>
310310
</pluginManagement>
311311
</build>
312+
313+
<profiles>
314+
<profile>
315+
<id>shade</id>
316+
<build>
317+
<plugins>
318+
<plugin>
319+
<groupId>org.apache.maven.plugins</groupId>
320+
<artifactId>maven-shade-plugin</artifactId>
321+
<configuration>
322+
<relocations>
323+
<relocation>
324+
<pattern>com</pattern>
325+
<shadedPattern>com.google.cloud.spanner.jdbc.shaded.com</shadedPattern>
326+
<excludes>
327+
<exclude>com.google.cloud.spanner.**</exclude>
328+
</excludes>
329+
</relocation>
330+
<relocation>
331+
<pattern>android</pattern>
332+
<shadedPattern>com.google.cloud.spanner.jdbc.shaded.android</shadedPattern>
333+
</relocation>
334+
<relocation>
335+
<pattern>io</pattern>
336+
<shadedPattern>com.google.cloud.spanner.jdbc.shaded.io</shadedPattern>
337+
<excludes>
338+
<exclude>io.grpc.netty.shaded.**</exclude>
339+
</excludes>
340+
</relocation>
341+
<relocation>
342+
<pattern>org</pattern>
343+
<shadedPattern>com.google.cloud.spanner.jdbc.shaded.org</shadedPattern>
344+
<excludes>
345+
<exclude>org.conscrypt.**</exclude>
346+
</excludes>
347+
</relocation>
348+
</relocations>
349+
</configuration>
350+
</plugin>
351+
</plugins>
352+
</build>
353+
</profile>
354+
</profiles>
355+
312356
<reporting>
313357
<plugins>
314358
<plugin>

0 commit comments

Comments
 (0)