Closed Valrog closed 7 years ago
For Maven we don't even have a plugin, so I see no reason why you couldn't adapt the example pom to use Shade. I wouldn't recommend it though, as even the smallest code change in your actual app jar would cause every user to have to download the entire app again. Having many small files is a major advantage, and I don't see a single disadvantage to that approach. Do you?
Normally I would agree, but in this specific case I am in need of a single jar file for this particular problem. As it turns out, it is easier for my project to be deployed through a single file, since it is not very big to begin with. Since only a handful of collaborators will have access to it as well, I don't believe it will be too tasking when I update it.
One quick question Edvin, if I may. I have managed to adjust the code as I wanted it, but I still require some external files to be uploaded and included in the app.xml. Is there an elegant way of achieving this? I realize this doesn't exactly pertain to your work here, but I would really appreciate your help on the matter (I'm coming from a heavy C++ background so I'm still getting the hang of this). Thank you for your quick reply.
I see. The easiest solution would be to put those external files in the folder you point to when you generate the manifest. If that's not an option, you can for sure read in the Manifest and add several files to it manually before writing it out again. That could be a separate built step you execute with the maven exec:jar goal perhaps.
Some pseudo code:
FXManifest manifest = JAXB.unmarshal(file, FXManifest.class);
LibraryFile externalFile = new LibraryFile(basePath, filePath);
manifest.files.add(externalFile);
JAXB.marshal(manifest, file);
I hope this is what you're looking for :)
Could you provide an example where to put those files when generating the manifest? I am having trouble deducing how exactly is the manifest being made.
Edit: I've figured it out. It turns out I was missing the include-extensions argument in my pom file. Once again, thank your for your help. Take care.
@Valrog there is now an example in the README.md where, in this case, one file is copied from the src/main/resources directory into the target/app directory. Basically it looks like this:
<execution>
<id>copy-whatsnewfile</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>jar</executable>
<workingDirectory>${app.dir}</workingDirectory>
<arguments>
<argument>uf</argument>
<argument>fxlauncher.jar</argument>
<argument>-C</argument>
<argument>${project.basedir}/src/main/resources</argument>
<argument>whatsnew.html</argument>
</arguments>
</configuration>
</execution>
In your case where you want to only use the fatjar its possible by adjusting the way the target/app directory is filled. Normally its done by copying all the dependencies into the directories. Just copy the fatjar into it and dont use the copy-dependencies plugin
@ronsmits I see, this is a much more elegant solution than what I've come up with. Thanks!
@Valrog thanks I will close the ticket
I was wondering if it's possible to adjust the plugin so it just updates the main fat jar (made with Shade plugin) instead of copying every possible dependency.