Object JarUtilities.Companion
-
- All Implemented Interfaces:
public class JarUtilities.Companion
-
-
Field Summary
Fields Modifier and Type Field Description public final static JarUtilities.CompanionINSTANCE
-
Method Summary
Modifier and Type Method Description final UnitcopyFileFromJar(String fileToCopy, Boolean replaceIfExists, Class<?> classToCopyFrom, String directory)Copy a file from inside our JAR-file to the host filesystem. final BooleancopyFileFromJar(String fileToCopy, Class<?> identifierClass, String directory)Copy a file from inside our JAR-file to the host filesystem. final UnitcopyFileFromJar(String fileToCopy, File destinationFile, Boolean replaceIfExists, Class<?> identifierClass)Copy a file from inside our JAR-file to the host filesystem to the specified destination, replacing an already existing file. final BooleancopyFileFromJar(String fileToCopy, File destinationFile, Class<?> identifierClass)Copy a file from inside our JAR-file to the host filesystem to the specified destination. final UnitcopyFolderFromJar(Class<?> classToRetrieveHomeFor, String directoryToCopy, String destinationDirectory, String jarDirectoryPrefix, Regex fileEnding, File tempDir)Copy a folder from inside a JAR-file to the host filesystem. final HashMap<String, String>jarInformation(Class<?> classInJar)Retrieve information about the environment for the given class. -
-
Method Detail
-
copyFileFromJar
final Unit copyFileFromJar(String fileToCopy, Boolean replaceIfExists, Class<?> classToCopyFrom, String directory)
Copy a file from inside our JAR-file to the host filesystem. The file will create exactly as specified in the parameter.
Example:
copyFileFromJar(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 aslog4j2.xml
- Parameters:
fileToCopy- The source-file in the JAR you wish to copy outside the JAR.replaceIfExists- Whether to replace the file, if it already exists.classToCopyFrom- The class of the JAR from which you want to copy from.directory- The directory where the file should be copied to.
-
copyFileFromJar
final Boolean copyFileFromJar(String fileToCopy, Class<?> identifierClass, String directory)
Copy a file from inside our JAR-file to the host filesystem. The file will be created with exactly the same path specified in the parameter.
Example:
copyFileFromJar(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 aslog4j2.xml
- Parameters:
fileToCopy- The source-file in the JAR you wish to copy outside the JAR.identifierClass- The class of the JAR from which to get the resource.directory- The directory to copy the file to.- Returns:
trueif the file was created,falseotherwise.
-
copyFileFromJar
final Unit copyFileFromJar(String fileToCopy, File destinationFile, Boolean replaceIfExists, Class<?> identifierClass)
Copy a file from inside our JAR-file to the host filesystem to the specified destination, replacing an already existing file. The file will be created with exactly the same path specified in the parameter.
Example:
copyFileFromJar(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 aslog4j2.xml
- Parameters:
fileToCopy- The source-file in the JAR you wish to copy outside the JAR.destinationFile- The file to which to copy to.replaceIfExists- Whether to replace the file, if it already exists.identifierClass- The class of the JAR from which to get the resource.
-
copyFileFromJar
final Boolean copyFileFromJar(String fileToCopy, File destinationFile, Class<?> identifierClass)
Copy a file from inside our JAR-file to the host filesystem to the specified destination. The file will be created with exactly the same path specified in the parameter.
Example:
copyFileFromJar(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 aslog4j2.xml
- Parameters:
fileToCopy- The source-file in the JAR you wish to copy outside the JAR.destinationFile- The file to which to copy to.identifierClass- The class of the JAR from which to get the resource.- Returns:
trueif the file was created,falseotherwise.
-
copyFolderFromJar
final Unit copyFolderFromJar(Class<?> classToRetrieveHomeFor, String directoryToCopy, String destinationDirectory, String jarDirectoryPrefix, Regex fileEnding, File tempDir)
Copy a folder from inside a JAR-file to the host filesystem. The specified folder will be copied, along with all resources inside it, recursively, to the specified destination.<br>
- Parameters:
classToRetrieveHomeFor- Path to either the JAR-file from which to copy a folder from, or to the class when running in a dev-environment.directoryToCopy- Path to the directory inside the JAR-file you want to copy.destinationDirectory- Path to the destination directory you want to copy source to.jarDirectoryPrefix- A prefix to remove when checking for existence of source inside the JAR-file.fileEnding- The file-ending to filter for.
-
jarInformation
final HashMap<String, String> jarInformation(Class<?> classInJar)
Retrieve information about the environment for the given class.
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.
- Parameters:
classInJar- Class for which to acquire information about its JAR-file and system.- Returns:
A hashmap containing key-value-pairs with information about the JAR-file and system.
-
-
-
-