Package io.joshworks.snappy.maven.tools
Class Repackager
- java.lang.Object
-
- io.joshworks.snappy.maven.tools.Repackager
-
public class Repackager extends java.lang.ObjectUtility class that can be used to repackage an archive so that it can be executed using 'java -jar'.- Author:
- Phillip Webb, Andy Wilkinson
-
-
Constructor Summary
Constructors Constructor Description Repackager(java.io.File source)
-
Method Summary
Modifier and Type Method Description protected java.lang.StringfindMainMethod(java.util.jar.JarFile source)voidrepackage(Libraries libraries)Repackage the source file so that it can be run using 'java -jar'.voidrepackage(java.io.File destination, Libraries libraries)Repackage to the given destination so that it can be launched using ' java -jar'.voidrepackage(java.io.File destination, Libraries libraries, LaunchScript launchScript)Repackage to the given destination so that it can be launched using ' java -jar'.voidsetBackupSource(boolean backupSource)Sets if source files should be backed up when they would be overwritten.voidsetLayout(Layout layout)Sets the layout to use for the jar.voidsetMainClass(java.lang.String mainClass)Sets the main class that should be run.
-
-
-
Method Detail
-
setMainClass
public void setMainClass(java.lang.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.- Parameters:
mainClass- the main class name
-
setBackupSource
public void setBackupSource(boolean backupSource)
Sets if source files should be backed up when they would be overwritten.- Parameters:
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).- Parameters:
layout- the layout
-
repackage
public void repackage(Libraries libraries) throws java.io.IOException
Repackage the source file so that it can be run using 'java -jar'.- Parameters:
libraries- the libraries required to run the archive- Throws:
java.io.IOException- if the file cannot be repackaged
-
repackage
public void repackage(java.io.File destination, Libraries libraries) throws java.io.IOExceptionRepackage to the given destination so that it can be launched using ' java -jar'.- Parameters:
destination- the destination file (may be the same as the source)libraries- the libraries required to run the archive- Throws:
java.io.IOException- if the file cannot be repackaged
-
repackage
public void repackage(java.io.File destination, Libraries libraries, LaunchScript launchScript) throws java.io.IOExceptionRepackage to the given destination so that it can be launched using ' java -jar'.- Parameters:
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- Throws:
java.io.IOException- if the file cannot be repackaged- Since:
- 1.3.0
-
findMainMethod
protected java.lang.String findMainMethod(java.util.jar.JarFile source) throws java.io.IOException- Throws:
java.io.IOException
-
-