tooling/maven/camel-repackager-maven-plugin/README.md
This Maven plugin creates self-executing JARs using Spring Boot's loader tools, providing the same nested JAR structure that Spring Boot uses for its executable JARs.
Instead of creating traditional "fat JARs" where all dependencies are unpacked and merged into a single JAR (like maven-shade-plugin does), this plugin creates JARs with Spring Boot's nested structure:
example.jar
|
+-META-INF
| +-MANIFEST.MF
+-org
| +-springframework
| +-boot
| +-loader
| +-<spring boot loader classes>
+-BOOT-INF
+-classes
| +-<your application classes>
+-lib
+-dependency1.jar
+-dependency2.jar
Add the plugin to your pom.xml:
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-repackager-maven-plugin</artifactId>
<version>${camel.version}</version>
<executions>
<execution>
<id>repackage-executable</id>
<phase>package</phase>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<mainClass>com.example.MyMainClass</mainClass>
</configuration>
</execution>
</executions>
</plugin>
| Parameter | Description | Default | Required |
|---|---|---|---|
mainClass | The main class to use for the executable JAR | Yes | |
sourceJar | The source JAR file to repackage | ${project.build.directory}/${project.build.finalName}.jar | No |
outputDirectory | The output directory for the repackaged JAR | ${project.build.directory} | No |
finalName | The final name of the repackaged JAR (without extension) | ${project.build.finalName} | No |
backupSource | Whether to backup the source JAR | true | No |
Repackager class to create the nested structureBOOT-INF/lib/JarLauncher as the main class and your class as Start-Class| Aspect | maven-shade-plugin | camel-repackager |
|---|---|---|
| JAR Structure | Single flat JAR with all classes | Nested JARs with Spring Boot loader |
| Startup Time | Slower (all classes loaded) | Faster (on-demand loading) |
| Memory Usage | Higher (all classes in memory) | Lower (only used classes loaded) |
| Classpath Conflicts | Possible (overlapping files) | Avoided (separate JARs) |
| Debugging | Harder (merged classes) | Easier (original JAR structure) |
| File Size | Smaller (no duplication) | Slightly larger (loader overhead) |
See the Camel JBang launcher (dsl/camel-jbang/camel-launcher) for a real-world example of how this plugin is used.