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
Modifier and TypeClassDescriptionstatic interface
Callback interface used to present a warning when finding the main class takes too long. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener that will be triggered to display a warning if searching for the main class takes too long.protected String
findMainMethod
(JarFile source) final File
Return theFile
to use to back up the original source.protected final Layout
protected final File
protected final boolean
protected final boolean
isAlreadyPackaged
(File file) protected void
setBackupFile
(File backupFile) Sets theFile
to use to back up the original source.void
setIncludeRelevantJarModeJars
(boolean includeRelevantJarModeJars) Sets if jarmode jars relevant for the packaging should be automatically included.void
Sets the layers that should be used in the jar.void
Sets the layout to use for the jar.void
setLayoutFactory
(LayoutFactory layoutFactory) Sets the layout factory for the jar.void
setMainClass
(String mainClass) Sets the main class that should be run.protected final void
write
(JarFile sourceJar, Libraries libraries, AbstractJarWriter writer) protected final void
write
(JarFile sourceJar, Libraries libraries, AbstractJarWriter writer, boolean ensureReproducibleBuild)
-
Constructor Details
-
Packager
Create a newPackager
instance.- 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
-
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 theFile
to 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
-
findMainMethod
- Throws:
IOException
-
getBackupFile
Return theFile
to use to back up the original source.- Returns:
- the file to use to back up the original source
-
getSource
-
getLayout
-