Package io.joshworks.snappy.maven.tools
Class JarWriter
- java.lang.Object
-
- io.joshworks.snappy.maven.tools.JarWriter
-
public class JarWriter extends java.lang.ObjectWrites JAR content, ensuring valid directory entries are always create and duplicate items are ignored.- Author:
- Phillip Webb, Andy Wilkinson
-
-
Constructor Summary
Constructors Constructor Description JarWriter(java.io.File file)Create a newJarWriterinstance.JarWriter(java.io.File file, LaunchScript launchScript)Create a newJarWriterinstance.
-
Method Summary
Modifier and Type Method Description voidclose()Close the writer.voidwriteEntries(java.util.jar.JarFile jarFile)Write all entries from the specified jar file.voidwriteEntry(java.lang.String entryName, java.io.InputStream inputStream)Writes an entry.voidwriteLoaderClasses()Write the required spring-boot-loader classes to the JAR.voidwriteManifest(java.util.jar.Manifest manifest)Write the specified manifest.voidwriteNestedLibrary(java.lang.String destination, Library library)Write a nested library.
-
-
-
Constructor Detail
-
JarWriter
public JarWriter(java.io.File file) throws java.io.FileNotFoundException, java.io.IOExceptionCreate a newJarWriterinstance.- Parameters:
file- the file to write- Throws:
java.io.IOException- if the file cannot be openedjava.io.FileNotFoundException- if the file cannot be found
-
JarWriter
public JarWriter(java.io.File file, LaunchScript launchScript) throws java.io.FileNotFoundException, java.io.IOExceptionCreate a newJarWriterinstance.- Parameters:
file- the file to writelaunchScript- an optional launch script to prepend to the front of the jar- Throws:
java.io.IOException- if the file cannot be openedjava.io.FileNotFoundException- if the file cannot be found
-
-
Method Detail
-
writeManifest
public void writeManifest(java.util.jar.Manifest manifest) throws java.io.IOExceptionWrite the specified manifest.- Parameters:
manifest- the manifest to write- Throws:
java.io.IOException- of the manifest cannot be written
-
writeEntries
public void writeEntries(java.util.jar.JarFile jarFile) throws java.io.IOExceptionWrite all entries from the specified jar file.- Parameters:
jarFile- the source jar file- Throws:
java.io.IOException- if the entries cannot be written
-
writeEntry
public void writeEntry(java.lang.String entryName, java.io.InputStream inputStream) throws java.io.IOExceptionWrites an entry. TheinputStreamis closed once the entry has been written- Parameters:
entryName- The name of the entryinputStream- The stream from which the entry's data can be read- Throws:
java.io.IOException- if the write fails
-
writeNestedLibrary
public void writeNestedLibrary(java.lang.String destination, Library library) throws java.io.IOExceptionWrite a nested library.- Parameters:
destination- the destination of the librarylibrary- the library- Throws:
java.io.IOException- if the write fails
-
writeLoaderClasses
public void writeLoaderClasses() throws java.io.IOExceptionWrite the required spring-boot-loader classes to the JAR.- Throws:
java.io.IOException- if the classes cannot be written
-
close
public void close() throws java.io.IOExceptionClose the writer.- Throws:
java.io.IOException- if the file cannot be closed
-
-