Add support for unpacking nested JARs
Update the executable JAR code to automatically unpack any entries which include an entry comment starting `UNPACK:` to the temp folder. The existing Maven and Gradle plugins have been updated with new configuration options and the `spring-boot-tools` project has been updated to write the appropriate entry comment based on a flag passed in via the `Library` class. This support has been added to allow libraries such a JRuby (which assumes that `jruby-complete.jar` is always accessible as file) to work with Spring Boot executable jars. Fixes gh-1070
This commit is contained in:
@@ -511,6 +511,11 @@ The following configuration options are available:
|
||||
|`layout`
|
||||
|The type of archive, corresponding to how the dependencies are laid out inside
|
||||
(defaults to a guess based on the archive type).
|
||||
|
||||
|`requiresUnpack`
|
||||
|A list of dependencies (in the form ``groupId:artifactId'' that must be unpacked from
|
||||
fat jars in order to run. Items are still packaged into the fat jar, but they will be
|
||||
automatically unpacked when it runs.
|
||||
|===
|
||||
|
||||
|
||||
|
||||
@@ -1618,6 +1618,50 @@ For Gradle users the steps are similar. Example:
|
||||
|
||||
|
||||
|
||||
[[howto-extract-specific-libraries-when-an-executable-jar-runs]]
|
||||
=== Extract specific libraries when an executable jar runs
|
||||
Most nested libraries in an executable jar do not need to be unpacked in order to run,
|
||||
however, certain libraries can have problems. For example, JRuby includes its own nested
|
||||
jar support which assumes that the `jruby-complete.jar` is always directly available as a
|
||||
file in its own right.
|
||||
|
||||
To deal with any problematic libraries, you can flag that specific nested jars should be
|
||||
automatically unpacked to the ``temp folder'' when the executable jar first runs.
|
||||
|
||||
For example, to indicate that JRuby should be flagged for unpack using the Maven Plugin
|
||||
you would add the following configuration:
|
||||
|
||||
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<requiresUnpack>
|
||||
<dependency>
|
||||
<groupId>org.jruby</groupId>
|
||||
<artifactId>jruby-complete</artifactId>
|
||||
</dependency>
|
||||
</requiresUnpack>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
----
|
||||
|
||||
And to do that same with Gradle:
|
||||
|
||||
[source,groovy,indent=0,subs="verbatim,attributes"]
|
||||
----
|
||||
springBoot {
|
||||
requiresUnpack = ['org.jruby:jruby-complete']
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
|
||||
[[howto-create-a-nonexecutable-jar]]
|
||||
=== Create a non-executable JAR with exclusions
|
||||
Often if you have an executable and a non-executable jar as build products, the executable
|
||||
|
||||
Reference in New Issue
Block a user