3.16.13-windows64NewPackrTest

This commit is contained in:
yairm210
2021-09-10 12:30:09 +03:00
parent ec7897dc1a
commit 2c8bf658ed

View File

@ -62,31 +62,12 @@ tasks.register<Jar>("dist") { // Compiles the jar file
} }
} }
for(platform in PackrConfig.Platform.values()) { for (platform in PackrConfig.Platform.values()) {
val platformName = platform.toString() val platformName = platform.toString()
tasks.create("packr${platformName}") { tasks.create("packr${platformName}") {
dependsOn(tasks.getByName("dist")) dependsOn(tasks.getByName("dist"))
val jarFile = "$rootDir/desktop/build/libs/${BuildConfig.appName}.jar"
val config = PackrConfig()
config.platform = platform
if (platform == PackrConfig.Platform.Windows64)
config.jdk = "jdk-windows-64.zip" // see how we download and name this in travis yml
if (platform == PackrConfig.Platform.Windows32)
config.jdk = "jdk-windows-32.zip" // see how we download and name this in travis yml
config.apply {
executable = "Unciv"
classpath = listOf(jarFile)
removePlatformLibs = config.classpath
mainClass = mainClassName
vmArgs = listOf("Xmx1G")
minimizeJre = "desktop/packrConfig.json"
outDir = file("packr")
}
doLast { doLast {
// https://gist.github.com/seanf/58b76e278f4b7ec0a2920d8e5870eed6 // https://gist.github.com/seanf/58b76e278f4b7ec0a2920d8e5870eed6
@ -107,16 +88,41 @@ for(platform in PackrConfig.Platform.values()) {
println(process.inputStream.bufferedReader().readText()) println(process.inputStream.bufferedReader().readText())
} }
val jarFile = "$rootDir/desktop/build/libs/${BuildConfig.appName}.jar"
val config = PackrConfig()
config.platform = platform
config.apply {
executable = "Unciv"
classpath = listOf(jarFile)
removePlatformLibs = config.classpath
mainClass = mainClassName
vmArgs = listOf("Xmx1G")
minimizeJre = "desktop/packrConfig.json"
outDir = file("packr")
}
if (config.outDir.exists()) delete(config.outDir) if (config.outDir.exists()) delete(config.outDir)
// Requires that both packr and the linux jre are downloaded, as per buildAndDeploy.yml, "Upload to itch.io" // Requires that both packr and the jre are downloaded, as per buildAndDeploy.yml, "Upload to itch.io"
if (platform == PackrConfig.Platform.Linux64 || platform == PackrConfig.Platform.MacOS) {
// Use old version of packr - newer versions aren't Windows32-compliant
if (platform == PackrConfig.Platform.Windows32) {
config.jdk = "jdk-windows-32.zip"
Packr().pack(config)
} else {
val jdkFile = val jdkFile =
if (platform == PackrConfig.Platform.Linux64) "jre-linux-64.tar.gz" when (platform) {
else "jre-macOS.tar.gz" PackrConfig.Platform.Linux64 -> "jre-linux-64.tar.gz"
PackrConfig.Platform.Windows64 -> "jdk-windows-64.zip"
else -> "jre-macOS.tar.gz"
}
val platformNameForPackrCmd = val platformNameForPackrCmd =
if (platform == PackrConfig.Platform.Linux64) "linux64" if (platform == PackrConfig.Platform.MacOS) "mac"
else "mac" else platform.name.toLowerCase()
val command = "java -jar $rootDir/packr-all-4.0.0.jar" + val command = "java -jar $rootDir/packr-all-4.0.0.jar" +
" --platform $platformNameForPackrCmd" + " --platform $platformNameForPackrCmd" +
" --jdk $jdkFile" + " --jdk $jdkFile" +
@ -126,7 +132,7 @@ for(platform in PackrConfig.Platform.values()) {
" --vmargs Xmx1G " + (if (platform == PackrConfig.Platform.MacOS) "XstartOnFirstThread" else "") + " --vmargs Xmx1G " + (if (platform == PackrConfig.Platform.MacOS) "XstartOnFirstThread" else "") +
" --output ${config.outDir}" " --output ${config.outDir}"
command.runCommand(rootDir) command.runCommand(rootDir)
} else Packr().pack(config) }
} }
tasks.register<Zip>("zip${platformName}") { tasks.register<Zip>("zip${platformName}") {