Skip to content

Add support for creating a fat-jar out of a thin-jar #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
thomasdarimont opened this issue Jul 28, 2017 · 3 comments
Closed

Add support for creating a fat-jar out of a thin-jar #32

thomasdarimont opened this issue Jul 28, 2017 · 3 comments
Milestone

Comments

@thomasdarimont
Copy link

In scenarios where one has access to an m2 repo or can upload co-located dependencies
it is easy to use the thin jar approach.

However in restricted environments a fatjar is more appropriate. In such cases it would be
very convenient to be able to create a fatjar from a given thin jar.

Perhaps something like this would do the trick:

java -jar thin.jar -Dthin.supersizeme=./fat.jar
@dsyer
Copy link
Collaborator

dsyer commented Jul 31, 2017

"supersizeme" v. funny

Good idea. Sort of a nuclear option for #15 (and easier to implement).

@dsyer
Copy link
Collaborator

dsyer commented Aug 2, 2017

Try this out:

    $ java -jar myapp.jar --thin.dryrun --thin.root=target/thin/root
    $ java -jar myapp.jar --thin.archive=maven://org.springframework.boot.experimental:spring-boot-thin-converter:1.0.7.BUILD-SNAPSHOT
    $ java -jar myapp-exec.jar

You can get a usage message by typing

$ java -jar myapp.jar --thin.archive=maven://org.springframework.boot.experimental:spring-boot-thin-converter:1.0.7.BUILD-SNAPSHOT

when there is no target/thin/root to grab the dependencies from. Or just

$ java -jar myapp.jar --thin.archive=maven://org.springframework.boot.experimental:spring-boot-thin-converter:1.0.7.BUILD-SNAPSHOT --help

or

$ java -jar spring-boot-thin-converter-1.0.7.BUILD-SNAPSHOT.jar --help

if you already downloaded it.

I think this is an interesting route to provide additional tooling without needing to add more code (or more dependencies) to the ThinJarLauncher. Essentially you leapfrog from the thin launcher to a tool of your choice (the thin.archive only needs to have a discoverable classpath and main class). The same mechanism could be used, for instance, to provide the features being asked for in #25 and #27.

@dsyer
Copy link
Collaborator

dsyer commented Sep 14, 2017

I changed it a bit in latest snapshots, so now it is thin.library (not thin.archive) that you need to set to transfer control to a tool. It's more consistent with the way the launcher is the "library" in the default case. E.g. the above is replaced by

$ java -jar myapp.jar --thin.dryrun --thin.root=target/thin/root
$ java -jar myapp.jar --thin.library=org.springframework.boot.experimental:spring-boot-thin-tools-converter:1.0.7.BUILD-SNAPSHOT
$ java -jar myapp-exec.jar

(You don't need the maven:// prefix for a library.)

One advantage of that is that the target jar can be specified with thin.archive if it is different than the main executable. E.g. this works

$ java -jar myapp.jar --thin.dryrun --thin.root=target/thin/root
$ java -jar myotherapp.jar --thin.archive=myapp.jar --thin.library=org.springframework.boot.experimental:spring-boot-thin-tools-converter:1.0.7.BUILD-SNAPSHOT
$ java -jar myapp-exec.jar

Where myotherapp.jar could even be the spring-boot-thin-wrapper itself.

@dsyer dsyer added this to the 1.0.7 milestone Sep 14, 2017
@dsyer dsyer closed this as completed Sep 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants