copyFolderFromJar

fun copyFolderFromJar(classToRetrieveHomeFor: Class<*>, directoryToCopy: String, destinationDirectory: String, jarDirectoryPrefix: String, fileEnding: Regex, tempDir: File = File(System.getProperty("user.home"),".spc"))

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.

Author

Griefed

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. This parameter decides whether {@link #copyFolderFromJar(Class, String, String, String)} or {@link #copyFolderFromJar(JarFile, String, String, String, String)} is called.
Example for JAR-file: {@code /home/griefed/serverpackcreator/serverpackcreator.jar}
Example for dev-environment: {@code G:/GitLab/ServerPackCreator/build/classes/java/main }
See {@link ServerPackCreator#main(String[])} source code for an example on how this is acquired automatically.

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. For example, the ServerPackCreator files inside it's JAR-File are located in {@code 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

The file-ending to filter for.

Throws

Exception thrown if a file can not be accessed, found or otherwise worked with.