Skip to content

Commit

Permalink
fix: Add shaded jar for java-client and document its use (#9443)
Browse files Browse the repository at this point in the history
* fix: Add shaded jar for java-client and document its use

Addresses #7470 and #9245.
  • Loading branch information
jnh5y committed Sep 12, 2022
1 parent 45a8197 commit 2f86863
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/developer-guide/ksqldb-clients/java-client.md
Expand Up @@ -85,6 +85,7 @@ Start by creating a `pom.xml` for your Java application:
<groupId>io.confluent.ksql</groupId>
<artifactId>ksqldb-api-client</artifactId>
<version>${ksqldb.version}</version>
<classifier>with-dependencies</classifier>
</dependency>
</dependencies>

Expand Down Expand Up @@ -113,6 +114,21 @@ Start by creating a `pom.xml` for your Java application:
by replacing the repositories in the example POM above with a repository with this
URL instead. Also update `ksqldb.version` to be a CP version, such as `{{ site.cprelease }}`, instead.

!!! note
The `with-dependencies` artifact was introduced in ksqlDB version 0.29 and CP version 7.4.0. This jar includes
all the necessary dependencies and relocates most of them in an attempt to avoid classpath issues. Using this jar
provides the easiest way to get started.
If you want more control over the dependencies on the classpath, you can depend directly on the client
using this dependency block instead:
```
<dependency>
<groupId>io.confluent.ksql</groupId>
<artifactId>ksqldb-api-client</artifactId>
<version>${ksqldb.version}</version>
</dependency>
```
If you do this, you will need to add all the transitive dependencies for `ksqldb-api-client`.

Create your example app at `src/main/java/my/ksqldb/app/ExampleApp.java`:

```java
Expand Down
60 changes: 60 additions & 0 deletions ksqldb-api-client/pom.xml
Expand Up @@ -174,6 +174,66 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>with-dependencies</shadedClassifierName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
<relocations>
<relocation>
<pattern>com.fasterxml</pattern>
<shadedPattern>io.confluent.shaded.com.fasterxml</shadedPattern>
</relocation>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>io.confluent.shaded.com.google</shadedPattern>
</relocation>
<relocation>
<pattern>com.googlecode</pattern>
<shadedPattern>io.confluent.shaded.com.googlecode</shadedPattern>
</relocation>
<relocation>
<pattern>org.reactivestreams</pattern>
<shadedPattern>io.confluent.shaded.org.reactivestreams</shadedPattern>
</relocation>
<relocation>
<pattern>io.netty</pattern>
<shadedPattern>io.confluent.shaded.io.netty</shadedPattern>
</relocation>
<relocation>
<pattern>io.vertx</pattern>
<shadedPattern>io.confluent.shaded.io.vertx</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>io.confluent.shaded.org.slf4j</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand Down

0 comments on commit 2f86863

Please sign in to comment.