Linux64 is now built with packr JAR file, thus removing the need for JAVA_HOME!

This commit is contained in:
yairm210 2021-08-22 21:08:26 +03:00
parent 40e35b2167
commit 79f3aae803
2 changed files with 49 additions and 19 deletions

View File

@ -113,19 +113,25 @@ jobs:
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
run: |
wget -q -O jdk-windows-64.zip https://github.com/ojdkbuild/ojdkbuild/releases/download/java-1.8.0-openjdk-1.8.0.232-1.b09/java-1.8.0-openjdk-1.8.0.232-1.b09.ojdkbuild.windows.x86_64.zip
wget -q -O jdk-windows-32.zip https://github.com/ojdkbuild/ojdkbuild/releases/download/java-1.8.0-openjdk-1.8.0.252-2.b09-x86/java-1.8.0-openjdk-1.8.0.252-2.b09.ojdkbuild.windows.x86.zip
wget -q -O butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default
unzip butler.zip;
chmod +x butler;
./butler -V;
wget -q -O jdk-windows-32.zip https://github.com/ojdkbuild/ojdkbuild/releases/download/java-1.8.0-openjdk-1.8.0.252-2.b09-x86/java-1.8.0-openjdk-1.8.0.252-2.b09.ojdkbuild.windows.x86.zip
./gradlew desktop:packrWindows32;
./butler push deploy/Unciv-Windows32.zip yairm210/unciv:Windows32 --userversion ${{steps.tag.outputs.tag}};
./gradlew desktop:packrWindows64;
wget -q -O jdk-windows-64.zip https://github.com/ojdkbuild/ojdkbuild/releases/download/java-1.8.0-openjdk-1.8.0.232-1.b09/java-1.8.0-openjdk-1.8.0.232-1.b09.ojdkbuild.windows.x86_64.zip
./butler push deploy/Unciv-Windows64.zip yairm210/unciv:Windows64 --userversion ${{steps.tag.outputs.tag}};
wget -q -O jre-linux-64.tar.gz https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.11%2B9/OpenJDK11U-jre_x64_linux_hotspot_11.0.11_9.tar.gz
wget -q -O packr-all-4.0.0.jar https://github.com/libgdx/packr/releases/download/4.0.0/packr-all-4.0.0.jar
./gradlew desktop:packrLinux64;
./butler push deploy/Unciv-Linux64.zip yairm210/unciv:Linux64 --userversion ${{steps.tag.outputs.tag}};
./gradlew desktop:zipLinuxFilesForJar;
mv desktop/build/libs/Unciv.jar deploy/Unciv.jar
mv android/build/outputs/bundle/release/Unciv-release.aab deploy/Unciv.aab

View File

@ -73,25 +73,19 @@ for(platform in PackrConfig.Platform.values()) {
tasks.create("packr${platformName}") {
dependsOn(tasks.getByName("dist"))
val jarFile = "desktop/build/libs/${BuildConfig.appName}.jar"
val jarFile = "$rootDir/desktop/build/libs/${BuildConfig.appName}.jar"
val config = PackrConfig()
config.platform = platform
val forTravis = true // change to false for local build
if(forTravis) {
if (platform == PackrConfig.Platform.Linux32 || platform == PackrConfig.Platform.Linux64)
config.jdk = System.getenv("JAVA_HOME")
// take the jdk straight from the building linux computer
if (platform == PackrConfig.Platform.Linux32 || platform == PackrConfig.Platform.Linux64)
config.jdk = "jdk-linux-64.zip"
// take the jdk straight from the building linux computer
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
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
}
else {
// for my computer
config.jdk = "C:/Users/LENOVO/Downloads/java-1.8.0-openjdk-1.8.0.232-1.b09.ojdkbuild.windows.x86_64.zip"
}
config.apply {
executable = "Unciv"
classpath = listOf(jarFile)
@ -104,8 +98,38 @@ for(platform in PackrConfig.Platform.values()) {
doLast {
if(config.outDir.exists()) delete(config.outDir)
Packr().pack(config)
// https://gist.github.com/seanf/58b76e278f4b7ec0a2920d8e5870eed6
fun String.runCommand(workingDir: File) {
val process = ProcessBuilder(*split(" ").toTypedArray())
.directory(workingDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()
if (!process.waitFor(30, TimeUnit.SECONDS)) {
process.destroy()
throw RuntimeException("execution timed out: $this")
}
if (process.exitValue() != 0) {
throw RuntimeException("execution failed with code ${process.exitValue()}: $this")
}
println(process.inputStream.bufferedReader().readText())
}
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"
if (platform == PackrConfig.Platform.Linux64) {
val command = "java -jar $rootDir/packr-all-4.0.0.jar" +
" --platform linux64" +
" --jdk jre-linux-64.tar.gz" +
" --executable Unciv" +
" --classpath $jarFile" +
" --mainclass $mainClassName" +
" --vmargs Xmx1G" +
" --output ${config.outDir}"
command.runCommand(rootDir)
} else Packr().pack(config)
}
tasks.register<Zip>("zip${platformName}") {