public class JarWriter extends Object implements LoaderClassesWriter, AutoCloseable
Constructor and Description |
---|
JarWriter(File file)
Create a new
JarWriter instance. |
JarWriter(File file,
LaunchScript launchScript)
Create a new
JarWriter instance. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the writer.
|
void |
writeEntries(JarFile jarFile)
Write all entries from the specified jar file.
|
void |
writeEntry(String entryName,
InputStream inputStream)
Writes an entry.
|
void |
writeLoaderClasses()
Write the required spring-boot-loader classes to the JAR.
|
void |
writeLoaderClasses(String loaderJarResourceName)
Write the required spring-boot-loader classes to the JAR.
|
void |
writeManifest(Manifest manifest)
Write the specified manifest.
|
void |
writeNestedLibrary(String destination,
Library library)
Write a nested library.
|
public JarWriter(File file) throws FileNotFoundException, IOException
JarWriter
instance.file
- the file to writeIOException
- if the file cannot be openedFileNotFoundException
- if the file cannot be foundpublic JarWriter(File file, LaunchScript launchScript) throws FileNotFoundException, IOException
JarWriter
instance.file
- the file to writelaunchScript
- an optional launch script to prepend to the front of the jarIOException
- if the file cannot be openedFileNotFoundException
- if the file cannot be foundpublic void writeManifest(Manifest manifest) throws IOException
manifest
- the manifest to writeIOException
- of the manifest cannot be writtenpublic void writeEntries(JarFile jarFile) throws IOException
jarFile
- the source jar fileIOException
- if the entries cannot be writtenpublic void writeEntry(String entryName, InputStream inputStream) throws IOException
inputStream
is closed once the entry has been writtenwriteEntry
in interface LoaderClassesWriter
entryName
- the name of the entryinputStream
- the stream from which the entry's data can be readIOException
- if the write failspublic void writeNestedLibrary(String destination, Library library) throws IOException
destination
- the destination of the librarylibrary
- the libraryIOException
- if the write failspublic void writeLoaderClasses() throws IOException
writeLoaderClasses
in interface LoaderClassesWriter
IOException
- if the classes cannot be writtenpublic void writeLoaderClasses(String loaderJarResourceName) throws IOException
writeLoaderClasses
in interface LoaderClassesWriter
loaderJarResourceName
- the name of the resource containing the loader classes
to be writtenIOException
- if the classes cannot be writtenpublic void close() throws IOException
close
in interface AutoCloseable
IOException
- if the file cannot be closedCopyright © 2020 Pivotal Software, Inc.. All rights reserved.