Skip to content

Commit

Permalink
feat: add uber JAR capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
tmetzke committed Nov 3, 2022
1 parent d1bc1a6 commit 44ab503
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,27 @@ Camunda Connector Template

## Build

You can package the Connector by running the following command:

```bash
mvn clean package
```

This will create the following artifacts:

- A thin JAR without dependencies.
- An uber JAR containing all dependencies, potentially shaded to avoid classpath conflicts.

### Shading dependencies

You can use the `maven-shade-plugin` defined in the [Maven configuration](./pom.xml) to relocate common dependencies
that are used in other Connectors and the [Connector Runtime](https://github.com/camunda/connector-sdk/tree/main/runtime).
This helps avoiding classpath conflicts when the Connector is executed.

Use the `relocations` configuration in the Maven Shade plugin to define the dependencies that should be shaded.
The [Maven Shade documentation](https://maven.apache.org/plugins/maven-shade-plugin/examples/class-relocation.html)
provides more details on relocations.

## API

### Input
Expand Down
64 changes: 63 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<plugin.version.maven-install-plugin>3.0.1</plugin.version.maven-install-plugin>
<plugin.version.maven-jar-plugin>3.2.2</plugin.version.maven-jar-plugin>
<plugin.version.maven-resources-plugin>3.3.0</plugin.version.maven-resources-plugin>
<plugin.version.maven-shade-plugin>3.4.1</plugin.version.maven-shade-plugin>
<plugin.version.maven-surefire-plugin>3.0.0-M7</plugin.version.maven-surefire-plugin>
</properties>

Expand Down Expand Up @@ -63,13 +64,20 @@
<version>${version.mockito}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${version.assertj}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>${version.slf4j}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -108,13 +116,67 @@
<artifactId>maven-install-plugin</artifactId>
<version>${plugin.version.maven-install-plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${plugin.version.maven-shade-plugin}</version>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>with-dependencies</shadedClassifierName>
<!-- no need for this since we are not consuming this artifact downstream -->
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>module-info.class</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<!-- This is needed if you have dependencies that use Service Loader. Most Google Cloud client libraries does. -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<!-- This is needed to not repeat licenses in the META-INF directory -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer"/>
<!-- This is needed to merge existing NOTICE files and keep them downstream -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
<addHeader>false</addHeader>
</transformer>
</transformers>
<!-- include relocation to shade dependencies inside your JAR -->
<!--<relocations>
<relocation>
<pattern>com.fasterxml.jackson</pattern>
<shadedPattern>myconnector.com.fasterxml.jackson</shadedPattern>
</relocation>
</relocations>-->
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${plugin.version.maven-surefire-plugin}</version>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
</build>

<repositories>
Expand Down

0 comments on commit 44ab503

Please sign in to comment.