Class Packager
java.lang.Object
org.springframework.boot.loader.tools.Packager
- Direct Known Subclasses:
ImagePackager,Repackager
Abstract base class for packagers.
- Since:
- 2.3.0
- Author:
- Phillip Webb, Andy Wilkinson, Stephane Nicoll, Madhura Bhave, Scott Frederick
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCallback interface used to present a warning when finding the main class takes too long. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a listener that will be triggered to display a warning if searching for the main class takes too long.protected StringfindMainMethod(JarFile source) final FileReturn theFileto use to back up the original source.protected final Layoutprotected final Fileprotected final booleanprotected final booleanisAlreadyPackaged(File file) protected voidsetBackupFile(File backupFile) Sets theFileto use to back up the original source.voidsetIncludeRelevantJarModeJars(boolean includeRelevantJarModeJars) Sets if jarmode jars relevant for the packaging should be automatically included.voidSets the layers that should be used in the jar.voidSets the layout to use for the jar.voidsetLayoutFactory(LayoutFactory layoutFactory) Sets the layout factory for the jar.voidsetLoaderImplementation(LoaderImplementation loaderImplementation) Sets the loader implementation to use.voidsetMainClass(String mainClass) Sets the main class that should be run.protected final voidwrite(JarFile sourceJar, Libraries libraries, AbstractJarWriter writer) protected final voidwrite(JarFile sourceJar, Libraries libraries, AbstractJarWriter writer, boolean ensureReproducibleBuild) protected voidwriteSignatureFileIfNecessary(Map<String, Library> writtenLibraries, AbstractJarWriter writer) Writes a signature file if necessary for the givenwrittenLibraries.
-
Constructor Details
-
Packager
Create a newPackagerinstance.- Parameters:
source- the source archive file to package
-
-
Method Details
-
addMainClassTimeoutWarningListener
Add a listener that will be triggered to display a warning if searching for the main class takes too long.- Parameters:
listener- the listener to add
-
setMainClass
Sets the main class that should be run. If not specified the value from the MANIFEST will be used, or if no manifest entry is found the archive will be searched for a suitable class.- Parameters:
mainClass- the main class name
-
setLayout
Sets the layout to use for the jar. Defaults toLayouts.forFile(File).- Parameters:
layout- the layout
-
setLoaderImplementation
Sets the loader implementation to use.- Parameters:
loaderImplementation- the loaderImplementation to set
-
setLayoutFactory
Sets the layout factory for the jar. The factory can be used when no specific layout is specified.- Parameters:
layoutFactory- the layout factory to set
-
setLayers
Sets the layers that should be used in the jar.- Parameters:
layers- the jar layers
-
setBackupFile
Sets theFileto use to back up the original source.- Parameters:
backupFile- the file to use to back up the original source
-
setIncludeRelevantJarModeJars
public void setIncludeRelevantJarModeJars(boolean includeRelevantJarModeJars) Sets if jarmode jars relevant for the packaging should be automatically included.- Parameters:
includeRelevantJarModeJars- if relevant jars are included
-
isAlreadyPackaged
protected final boolean isAlreadyPackaged() -
isAlreadyPackaged
-
write
protected final void write(JarFile sourceJar, Libraries libraries, AbstractJarWriter writer) throws IOException - Throws:
IOException
-
write
protected final void write(JarFile sourceJar, Libraries libraries, AbstractJarWriter writer, boolean ensureReproducibleBuild) throws IOException - Throws:
IOException
-
writeSignatureFileIfNecessary
protected void writeSignatureFileIfNecessary(Map<String, Library> writtenLibraries, AbstractJarWriter writer) throws IOExceptionWrites a signature file if necessary for the givenwrittenLibraries.- Parameters:
writtenLibraries- the librarieswriter- the writer to use to write the signature file if necessary- Throws:
IOException- if a failure occurs when writing the signature file
-
findMainMethod
- Throws:
IOException
-
getBackupFile
Return theFileto use to back up the original source.- Returns:
- the file to use to back up the original source
-
getSource
-
getLayout
-