public class JarUtilities
extends java.lang.Object
| Constructor and Description |
|---|
JarUtilities() |
| Modifier and Type | Method and Description |
|---|---|
void |
copyFileFromJar(java.io.File fileToCopy,
boolean replace,
java.lang.Class<?> classToCopyFrom)
Copy a file from inside our JAR-file to the host filesystem.
|
void |
copyFileFromJar(java.io.File fileToCopy,
java.lang.Class<?> classToCopyFrom)
Copy a file from inside our JAR-file to the host filesystem.
|
void |
copyFolderFromJar(java.lang.Class<?> classToRetrieveHomeFor,
java.lang.String directoryToCopy,
java.lang.String destinationDirectory,
java.lang.String jarDirectoryPrefix,
java.lang.String fileEnding)
Copy a folder from inside a JAR-file to the host filesystem.
|
org.springframework.boot.system.ApplicationHome |
getApplicationHomeForClass(java.lang.Class<?> classToRetrieveHomeFor)
Retrieve the ApplicationHome for a given class.
|
java.util.HashMap<java.lang.String,java.lang.String> |
systemInformation(org.springframework.boot.system.ApplicationHome applicationHome)
Retrieve information about the environment for the given instance of
ApplicationHome, stored in a HashMap.Available key-value-pairs: jarPath - The path to the JAR-file. jarName - The name of the JAR-file. javaVersion - The version of the Java installation used. osArch - Architecture of the system. osName - Name of the operating system. osVersion - Version of the operating system. |
public void copyFileFromJar(java.io.File fileToCopy,
boolean replace,
java.lang.Class<?> classToCopyFrom)
copyFileFromJar(new File("log4j2.xml")) will result in the log4j2.xml file from inside the JAR-file to be copied
to the outside of the JAR-file as log4j2.xmlfileToCopy - File. The source-file in the JAR you wish to copy outside the JAR.replace - Boolean. Whether to replace the file, if it already exists.classToCopyFrom - Class. The class of the JAR from which you want to copy from.public void copyFileFromJar(java.io.File fileToCopy,
java.lang.Class<?> classToCopyFrom)
copyFileFromJar(new File("log4j2.xml")) will result in the log4j2.xml file from inside the JAR-file to be copied
to the outside of the JAR-file as log4j2.xmlfileToCopy - File. The source-file in the JAR you wish to copy outside the JAR.classToCopyFrom - Class. The class of the JAR from which to get the resource.public org.springframework.boot.system.ApplicationHome getApplicationHomeForClass(java.lang.Class<?> classToRetrieveHomeFor)
classToRetrieveHomeFor - Class. The class to retrieve the ApplicationHome for.ApplicationHome for the given class.public java.util.HashMap<java.lang.String,java.lang.String> systemInformation(org.springframework.boot.system.ApplicationHome applicationHome)
ApplicationHome, stored in a HashMap.applicationHome - Instance of ApplicationHome from which to gather information about the JAR-file and system.public void copyFolderFromJar(java.lang.Class<?> classToRetrieveHomeFor,
java.lang.String directoryToCopy,
java.lang.String destinationDirectory,
java.lang.String jarDirectoryPrefix,
java.lang.String fileEnding)
throws java.io.IOException
classToRetrieveHomeFor - String. Path to either the JAR-file from which to copy a folder from, or to the class when running
in a dev-environment. This parameter decides whether copyFolderFromJar(Class,String, String, String) or
copyFolderFromJar(JarFile, String, String, String, String) is called./home/griefed/serverpackcreator/serverpackcreator.jarG:/GitLab/ServerPackCreator/build/classes/java/mainMain.main(String[]) source code for an example on how this is acquired automatically.directoryToCopy - String. Path to the directory inside the JAR-file you want to copy.destinationDirectory - String. Path to the destination directory you want to copy source to.jarDirectoryPrefix - String. A prefix to remove when checking for existence of source inside the JAR-file. For example,
the ServerPackCreator files inside it's JAR-File are located in BOOT-INF/classes due
to SpringBoot. In order to correctly scan for source, we need to remove that prefix, so we receive
a path that looks like a regular path inside a JAR-file.fileEnding - String. The file-ending to filter for.java.io.IOException - Exception thrown if a file can not be accessed, found or otherwise worked with.