Add a command to produce a self-contained executable JAR for a CLI app
A new command, jar, has been added to the CLI. The command can be used to create a self-contained executable JAR file from a CLI app. Basic usage is: spring jar <jar-name> <source-files> For example: spring jar my-app.jar *.groovy The resulting jar will contain the classes generated by compiling the source files, all of the application's dependencies, and entries on the application's classpath. By default a CLI application has the current working directory on its classpath. This can be overridden using the --classpath option. Any file that is referenced directly by the classpath is always included in the jar. Any file that is found a result of being contained within a directory that is on the classpath is subject to filtering to determine whether or not it should be included. The default includes are public/**, static/**, resources/**, META-INF/**, *. The default excludes are .*, repository/**, build/**, target/**. To be included in the jar, a file must match one of the includes and none of the excludes. The filters can be overridden using the --include and --exclude options. Closes #241
This commit is contained in:
@@ -45,7 +45,7 @@ import java.util.zip.ZipEntry;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class JarWriter {
|
||||
public class JarWriter {
|
||||
|
||||
private static final String NESTED_LOADER_JAR = "META-INF/loader/spring-boot-loader.jar";
|
||||
|
||||
@@ -107,6 +107,18 @@ class JarWriter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an entry. The {@code inputStream} is closed once the entry has been written
|
||||
*
|
||||
* @param entryName The name of the entry
|
||||
* @param inputStream The stream from which the entry's data can be read
|
||||
* @throws IOException if the write fails
|
||||
*/
|
||||
public void writeEntry(String entryName, InputStream inputStream) throws IOException {
|
||||
JarEntry entry = new JarEntry(entryName);
|
||||
writeEntry(entry, new InputStreamEntryWriter(inputStream, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a nested library.
|
||||
* @param destination the destination of the library
|
||||
|
||||
Reference in New Issue
Block a user