类 Repackager
- java.lang.Object
- org.springframework.boot.loader.tools.Repackager
public class Repackager extends Object
Utility class that can be used to repackage an archive so that it can be executed using 'java -jar'.
嵌套类概要
嵌套类 修饰符和类型 类 说明 static interface
Repackager.MainClassTimeoutWarningListener
Callback interface used to present a warning when finding the main class takes too long.
构造器概要
构造器 构造器 说明 Repackager(File source)
Repackager(File source, LayoutFactory layoutFactory)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
addMainClassTimeoutWarningListener(Repackager.MainClassTimeoutWarningListener listener)
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)
File
getBackupFile()
Return theFile
to use to backup the original source.void
repackage(File destination, Libraries libraries)
Repackage to the given destination so that it can be launched using ' java -jar'.void
repackage(File destination, Libraries libraries, LaunchScript launchScript)
Repackage to the given destination so that it can be launched using ' java -jar'.void
repackage(Libraries libraries)
Repackage the source file so that it can be run using 'java -jar'.void
setBackupSource(boolean backupSource)
Sets if source files should be backed up when they would be overwritten.void
setLayout(Layout layout)
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.
构造器详细资料
Repackager
public Repackager(File source)
Repackager
public Repackager(File source, LayoutFactory layoutFactory)
方法详细资料
addMainClassTimeoutWarningListener
public void addMainClassTimeoutWarningListener(Repackager.MainClassTimeoutWarningListener listener)
Add a listener that will be triggered to display a warning if searching for the main class takes too long.- 参数:
listener
- the listener to add
setMainClass
public void setMainClass(String mainClass)
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.- 参数:
mainClass
- the main class name
setBackupSource
public void setBackupSource(boolean backupSource)
Sets if source files should be backed up when they would be overwritten.- 参数:
backupSource
- if source files should be backed up
setLayout
public void setLayout(Layout layout)
Sets the layout to use for the jar. Defaults toLayouts.forFile(File)
.- 参数:
layout
- the layout
setLayoutFactory
public void setLayoutFactory(LayoutFactory layoutFactory)
Sets the layout factory for the jar. The factory can be used when no specific layout is specified.- 参数:
layoutFactory
- the layout factory to set
repackage
public void repackage(Libraries libraries) throws IOException
Repackage the source file so that it can be run using 'java -jar'.- 参数:
libraries
- the libraries required to run the archive- 抛出:
IOException
- if the file cannot be repackaged
repackage
public void repackage(File destination, Libraries libraries) throws IOException
Repackage to the given destination so that it can be launched using ' java -jar'.- 参数:
destination
- the destination file (may be the same as the source)libraries
- the libraries required to run the archive- 抛出:
IOException
- if the file cannot be repackaged
repackage
public void repackage(File destination, Libraries libraries, LaunchScript launchScript) throws IOException
Repackage to the given destination so that it can be launched using ' java -jar'.- 参数:
destination
- the destination file (may be the same as the source)libraries
- the libraries required to run the archivelaunchScript
- an optional launch script prepended to the front of the jar- 抛出:
IOException
- if the file cannot be repackaged- 从以下版本开始:
- 1.3.0
getBackupFile
public final File getBackupFile()
Return theFile
to use to backup the original source.- 返回:
- the file to use to backup the original source
findMainMethod
protected String findMainMethod(JarFile source) throws IOException
- 抛出:
IOException