chrisdchristo / capsule-maven-plugin

Capsule Maven Plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request: Integrate with Maven assembly

Downchuck opened this issue · comments

Like execPluginConfig, it would be nice to have an execAssemblyConfig which would re-processes a JAR created by the maven assembly plugin, to add in Capsule and generate a new jar.

In shell it looks like this, with a project that's currently using maven assembly to spit out a typical jar with dependencies:

cd project
mvn clean
mvn -DskipTests package
tar -xf target/project-SNAPSHOT-jar-with-dependencies.jar -C target/classes
rm target/classes/META-INF/MANIFEST.MF
mvn capsule:build

As an aside, the rm command is necessary because capsule maven does not skip existing manifest files, resulting in a build error when the generated manifest is added.

Perhaps you can provide an example project containing an assembly build. And from that describe how you want the eventual capsule to look like. Just so I am sure I understand what exactly you want.

I am distributing JARs that can be run from command line on a user machine, using Capsule to download dependencies, but run as normal on the target environment, where some dependencies are already present, and the JAR is loaded through a class loader. Think Hadoop or Tomcat, where something else is loading the JAR, but the JAR (or war) does contain a subset of dependencies.

I don't know that the feature is worth it, given that it's a one-off feature. That said, here's the other bug I encountered (needing the rm command):
https://github.com/chrischristo/capsule-maven-plugin/blob/b9ebc64089c82cfe08cbaba48ec3c72addf6b6d6/src/main/java/capsule/CapsuleMojo.java#L329
This addToJar command will throw an uncaught exception if a MANIFEST.MF file already exists in target/classes.

Actually there was a recent addition to the plugin where you can specify <fileSets>. See here for more info. But essentially you don't need to add the jar to target manually. Just include it in a fileSet and the plugin will add it to the capsule:

<fileSets>
  <fileSet>
    <directory>target/</directory>
    <outputDirectory>/</outputDirectory>
    <includes>
      <include>project-SNAPSHOT-jar-with-dependencies.jar</include>
    </includes>
  </fileSet>
</fileSets>

So any jar, zip, war, or whatever you create with an assembly plugin, you can use the <fileSets> tag to add those to the capsule. Hopefully this is sufficient for your needs?

I also fixed the MANIFEST.MF issue (which will be for the next release).