Skip to content
Snippets Groups Projects
Verified Commit 3099c703 authored by Griefed's avatar Griefed :joystick:
Browse files

fix: Properly copy manifests and themes

parent ba6936cf
No related branches found
No related tags found
2 merge requests!588Version 6,!587Bring alpha into beta
Showing
with 97 additions and 585 deletions
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Debug Fat Jar" type="JarApplication">
<option name="JAR_PATH" value="$PROJECT_DIR$/serverpackcreator-app/build/libs/serverpackcreator-app-dev.jar" />
<option name="PROGRAM_PARAMETERS" value="-web" />
<option name="WORKING_DIRECTORY" value="F:\GitLab\ServerPackCreator - ms6\serverpackcreator-app\tests" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="temurin-21" />
<method v="2">
<option name="Gradle.BeforeRunTask" enabled="false" tasks="clean build" externalProjectPath="$PROJECT_DIR$" vmOptions="" scriptParameters=" --info --full-stacktrace -x :serverpackcreator-api:test -x :serverpackcreator-app:test" />
</method>
......
......@@ -469,16 +469,11 @@ class ApiWrapper private constructor(
}
try {
var manifestPrefix = "BOOT-INF/classes"
if (apiProperties.isExe()) {
manifestPrefix = ""
//source = "de/griefed/resources/manifests"
}
utilities.jarUtilities.copyFolderFromJar(
this.javaClass,
"de/griefed/resources/manifests",
apiProperties.manifestsDirectory.absolutePath,
manifestPrefix,
"",
xmlJsonRegex,
apiProperties.tempDirectory
)
......
......@@ -29,7 +29,7 @@ import java.util.*
private val nested = ".*[.]jar!.*[.]jar".toRegex()
private val tmpDir = System.getProperty("java.io.tmpdir")
private const val JAR = "file:"
private const val FILE = "file:"
/**
* Acquire the JAR-file which contains this class. If JAR-file is a nested JAR-file, meaning the class is inside
......@@ -38,7 +38,6 @@ private const val JAR = "file:"
*
* In any case the returned file will give you access to the JAR-file which contains class from which this method was called,
* unless the class itself is nested more than one layer deep.
* @param rootOnly Whether only the root of the parent JAR-file should be considered, ignoring potential nesting of the class.
* @param tempDir The directory to which a nested JAR-file will be extracted to. If not specified, your systems default
* temp-directory will be used.
* @author Griefed
......@@ -52,7 +51,7 @@ fun <T : Any> Class<T>.source(
val url = classResource.toString()
val source: File?
if (url.startsWith(JAR)) {
if (url.startsWith(FILE)) {
try {
val uri = URI(url)
val file = Paths.get(uri).toFile()
......@@ -65,23 +64,29 @@ fun <T : Any> Class<T>.source(
source = File(jar.name)
}
if (source != null) {
return if (source.path.matches(nested)) {
val inner = source.path.toString().substring(source.path.toString().lastIndexOf("!"))
val nestedJar = File(inner.substring(2))
if (!tempDir.isDirectory) throw JarAccessException("Invalid temp-directory $tempDir.")
ZipFile(source.path.toString().replace(inner, "")).use {
it.extractFile(
nestedJar.toString(),
tempDir.path,
nestedJar.name
)
}
File(tempDir.path, nestedJar.name).absoluteFile
if (source == null) {
throw JarAccessException("Invalid Jar File URL String: clazz: $clazz, classResource: $classResource, url: $url")
}
return if (source.path.matches(nested)) {
val inner = source.path.toString().substring(source.path.toString().lastIndexOf("!"))
val nestedJar = File(inner.substring(2))
if (!tempDir.isDirectory) throw JarAccessException("Invalid temp-directory $tempDir.")
ZipFile(source.path.toString().replace(inner, "")).use {
it.extractFile(
nestedJar.toString(),
tempDir.path,
nestedJar.name
)
}
File(tempDir.path, nestedJar.name).absoluteFile
} else {
val tempSource = source.absolutePath
val newSource = if (tempSource.contains("!")) {
File(tempSource.substring(0, tempSource.indexOfFirst { letter -> letter == '!' }))
} else {
source
source.absoluteFile
}
newSource
}
throw JarAccessException("Invalid Jar File URL String: clazz: $clazz, classResource: $classResource, url: $url")
}
\ No newline at end of file
......@@ -252,6 +252,9 @@ class JarUtilities {
"/$dirToCopy"
}
try {
val classSource = classToCopyFrom.getResource(source)
val classUri = classSource.toURI()
val walkPath = classUri.toPath()
Files.walk(classToCopyFrom.getResource(source)?.toURI()?.toPath()).use {
for (path in it) {
val fileName = path.toString().replace("\\", "/")
......@@ -322,12 +325,15 @@ class JarUtilities {
while (entries.hasMoreElements()) {
val entry: JarEntry = entries.nextElement()
val entryName = entry.name
if (entryName.replace(jarDirectoryPrefix, "").startsWith("$directoryToCopy/")
&& entryName.matches(fileEnding)
) {
val check = if (jarDirectoryPrefix.isNotEmpty()) {
"$jarDirectoryPrefix/$directoryToCopy"
} else {
directoryToCopy
}
if (entryName.startsWith(check) && entryName.matches(fileEnding)) {
val destination = File(
destinationDirectory,
entryName.replace(jarDirectoryPrefix, "").replace(directoryToCopy, "")
entryName.replace(check, "")
).absoluteFile
log.debug("Destination: $destination")
if (!destination.exists()) {
......
## [6.0.0-alpha.4](https://git.griefed.de/Griefed/ServerPackCreator/compare/6.0.0-alpha.3...6.0.0-alpha.4) (2024-06-02)
### 🦊 CI/CD
* Merge cli, gui, web, updater into app ([9a70a19](https://git.griefed.de/Griefed/ServerPackCreator/commit/9a70a19d00e86cd86ff35883ebce3bd56cb177bd))
* Qodana does not support Java 21 yet ([e42477f](https://git.griefed.de/Griefed/ServerPackCreator/commit/e42477fced280e7977d0b9a84d9cdff7ee85bacf))
## [6.0.0-alpha.3](https://git.griefed.de/Griefed/ServerPackCreator/compare/6.0.0-alpha.2...6.0.0-alpha.3) (2024-06-02)
 
 
......
......@@ -297,20 +297,20 @@ class GuiProps(private val apiProperties: ApiProperties) {
32
)
val infoIcon = FlatSVGIcon("gui/svg/informationDialog.svg", defaultSize, defaultSize)
val warningIcon = FlatSVGIcon("gui/svg/warningDialog.svg", defaultSize, defaultSize)
val errorIcon = FlatSVGIcon("gui/svg/errorDialog.svg", defaultSize, defaultSize)
val checkmarkIcon = FlatSVGIcon("gui/svg/checkmark.svg", defaultSize, defaultSize)
val smallInfoIcon = FlatSVGIcon("gui/svg/informationDialog.svg", smallSize, smallSize)
val smallWarningIcon = FlatSVGIcon("gui/svg/warningDialog.svg", smallSize, smallSize)
val smallErrorIcon = FlatSVGIcon("gui/svg/errorDialog.svg", smallSize, smallSize)
val smallCheckmarkIcon = FlatSVGIcon("gui/svg/checkmark.svg", smallSize, smallSize)
val infoIcon = FlatSVGIcon("de/griefed/resources/gui/svg/informationDialog.svg", defaultSize, defaultSize)
val warningIcon = FlatSVGIcon("de/griefed/resources/gui/svg/warningDialog.svg", defaultSize, defaultSize)
val errorIcon = FlatSVGIcon("de/griefed/resources/gui/svg/errorDialog.svg", defaultSize, defaultSize)
val checkmarkIcon = FlatSVGIcon("de/griefed/resources/gui/svg/checkmark.svg", defaultSize, defaultSize)
val smallInfoIcon = FlatSVGIcon("de/griefed/resources/gui/svg/informationDialog.svg", smallSize, smallSize)
val smallWarningIcon = FlatSVGIcon("de/griefed/resources/gui/svg/warningDialog.svg", smallSize, smallSize)
val smallErrorIcon = FlatSVGIcon("de/griefed/resources/gui/svg/errorDialog.svg", smallSize, smallSize)
val smallCheckmarkIcon = FlatSVGIcon("de/griefed/resources/gui/svg/checkmark.svg", smallSize, smallSize)
val smallSettingsIcon = settingsIcon.getScaledInstance(smallSize, smallSize)
val smallHelpIcon = helpIcon.getScaledInstance(smallSize, smallSize)
val largeInfoIcon = FlatSVGIcon("gui/svg/informationDialog.svg", largeSize, largeSize)
val largeWarningIcon = FlatSVGIcon("gui/svg/warningDialog.svg", largeSize, largeSize)
val largeErrorIcon = FlatSVGIcon("gui/svg/errorDialog.svg", largeSize, largeSize)
val largeCheckmarkIcon = FlatSVGIcon("gui/svg/checkmark.svg", largeSize, largeSize)
val largeInfoIcon = FlatSVGIcon("de/griefed/resources/gui/svg/informationDialog.svg", largeSize, largeSize)
val largeWarningIcon = FlatSVGIcon("de/griefed/resources/gui/svg/warningDialog.svg", largeSize, largeSize)
val largeErrorIcon = FlatSVGIcon("de/griefed/resources/gui/svg/errorDialog.svg", largeSize, largeSize)
val largeCheckmarkIcon = FlatSVGIcon("de/griefed/resources/gui/svg/checkmark.svg", largeSize, largeSize)
val largeSettingsIcon = settingsIcon.getScaledInstance(largeSize, largeSize)
val largeHelpIcon = helpIcon.getScaledInstance(largeSize, largeSize)
val defaultFileChooserDimension = Dimension(750, 450)
......
......@@ -80,7 +80,7 @@ class ThemeManager(private val apiWrapper: ApiWrapper, private val guiProps: Gui
}
apiWrapper.utilities.jarUtilities.copyFolderFromJar(
this.javaClass,
"gui/themes",
"de/griefed/resources/gui/themes",
themesDir.absolutePath,
themesPrefix,
themeRegex,
......
......@@ -50,7 +50,7 @@ class ThirdPartyNoticesItem(private val mainFrame: MainFrame, private val guiPro
init {
thirdPartyNoticesWindowTextPane.isEditable = false
thirdPartyNoticesWindowTextPane.text =
this.javaClass.classLoader.getResource("gui/LICENSE-AGREEMENT")?.readText()
this.javaClass.classLoader.getResource("de/griefed/resources/gui/LICENSE-AGREEMENT")?.readText()
?: "Could not read resource. Please report this at https://github.com/Griefed/ServerPackCreator/issues/new?assignees=Griefed&labels=bug&projects=&template=bug-report.yml&title=%5BBug%5D%3A+"
this.addActionListener { displayThirdPartyNotices() }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment