Skip to content

Commit

Permalink
feat: Platform-specific distribution packages (#516)
Browse files Browse the repository at this point in the history
* feat(gradle): Bundle platform-spec. `.exe` files
* feat(gradle): bundle `TerasologyLauncher.app` for Mac distribution
* feat: add launch script for linux to top-level

* chore: clean up `jre.gradle`
* chore: rearrange build resources into `buildres` directory
* chore: delete `bundles` folder and unused gradle file

* fix: set fixed name for JAR for Windows `.exe`s to work

Co-authored-by: Niruandaleth <[email protected]>
  • Loading branch information
skaldarnar and jdrueckert authored Mar 21, 2020
1 parent fbe0abc commit 7713ecb
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 147 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ certum.jks
/src/main/resources/org/terasology/launcher/icons/

# Ignore version info file(s)
src/main/resources/org/terasology/launcher/version/
/src/main/resources/org/terasology/launcher/version/

# Ignore generated Web API sources
web-api-client/
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ plugins {
}

apply from: "./config/gradle/jre.gradle"
// TODO salvage useful bits and remove this
//apply from: "./config/gradle/bundles.gradle"
apply from: "./config/gradle/quality.gradle"
apply from: "./config/gradle/swagger.gradle"

Expand Down Expand Up @@ -164,6 +162,8 @@ task createVersionInfoFile {
processResources.dependsOn createVersionInfoFile

jar {
//TODO we only use this name because the `.exe` start scripts require the JAR to be named 'TerasologyLauncher.jar'
jar.archiveFileName = "${project.name}.jar"
// replace development "logback.xml" with productive "logback_jar.xml"
exclude "logback.xml"
rename('logback_jar.xml', 'logback.xml')
Expand Down
3 changes: 3 additions & 0 deletions buildres/linux/TerasologyLauncher.run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
echo "Starting TerasologyLauncher from './bin/TerasologyLauncher'"
sh ./bin/TerasologyLauncher
2 changes: 1 addition & 1 deletion bundles/macosx/Info.plist → buildres/mac/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<key>CFBundleDisplayName</key>
<string>Terasology</string>
<key>CFBundleExecutable</key>
<string>terasologylauncher.command</string>
<string>TerasologyLauncher</string>
<key>CFBundleIconFile</key>
<string>terasology.icns</string>
</dict>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions bundles/linux/run_linux.sh

This file was deleted.

3 changes: 0 additions & 3 deletions bundles/macosx/MacOS/terasologylauncher.command

This file was deleted.

93 changes: 0 additions & 93 deletions config/gradle/bundles.gradle

This file was deleted.

100 changes: 57 additions & 43 deletions config/gradle/jre.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

// Uses Bellsoft Liberica JRE
def jreVersion = '8u212'
def jreUrlBase = "https://download.bell-sw.com/java/$jreVersion/bellsoft-jre$jreVersion"
def jreUrlBase = "https://download.bell-sw.com/java/${jreVersion}/bellsoft-jre${jreVersion}"
def jreUrlFilenames = [
Linux64 : 'linux-amd64.tar.gz',
Linux32 : 'linux-i586.tar.gz',
Expand All @@ -36,67 +36,81 @@ task createRelease() {
}

task downloadJreAll {
group 'Download'
description 'Downloads JRE for all platforms'
group 'JRE'
description 'Downloads JREs for all platforms'
}

task unpackJreAll {
group 'JRE'
description 'Unpack JREs for all platforms'
}

def unpack(file) {
copySpec {
from((file.name.endsWith(".zip")) ? zipTree(file) : tarTree(file) ) {
eachFile { fcd ->
fcd.relativePath = new RelativePath(
true, fcd.relativePath.segments.drop(1))
}
includeEmptyDirs = false
}
}
}

jreUrlFilenames.each { os, file ->
def packedJre = new File("$projectDir/jre/$file")
def unpackedJre = new File("$buildDir/jre/$os")

def downloadTask = task("downloadJre$os") {
group 'Download'
def downloadTask = task "downloadJre${os}"(type: Download) {
group 'JRE'
description "Downloads JRE for $os"

doFirst {
download {
src "$jreUrlBase-$file"
dest packedJre
overwrite false
}
}
src "${jreUrlBase}-${file}"
dest "${projectDir}/jre/${file}"
overwrite false
}

doLast {
// Unpack the JRE
if (!unpackedJre.exists()) {
unpackedJre.mkdirs()
copy {
from(file.endsWith("zip")
? zipTree(packedJre)
: tarTree(packedJre)) {
eachFile { fcd ->
fcd.relativePath = new RelativePath(
true, fcd.relativePath.segments.drop(1))
}
includeEmptyDirs = false
}
into unpackedJre
}
}
}
def unpackTask = task "unpackJre${os}"(type: Copy) {
group 'JRE'
description "Unpack JRE for ${os} to distribution sources"
dependsOn downloadTask

with unpack(downloadTask.dest)
into "${buildDir}/jre/${os}"
}

def distName = os.toLowerCase()
distributions {
"$distName" {
def distName = os.toLowerCase()
def distBase = distName.replaceAll("\\d", "") // drop '32' or '64'

"${distName}" {
contents {
with distributions.main.contents

into('jre') {
from unpackedJre
from unpackTask
}

from("${projectDir}/buildres/${distBase}")
from("${projectDir}/buildres/${distName}")
}
}
}

def zipTask = tasks.named("${distName}DistZip").get()
def tarTask = tasks.named("${distName}DistTar").get()

downloadJreAll.dependsOn downloadTask
zipTask.dependsOn downloadTask
zipTask.description "Bundles the project with a JRE for $os"
tarTask.dependsOn downloadTask
tarTask.description "Bundles the project with a JRE for $os"
createRelease.dependsOn zipTask
unpackJreAll.dependsOn unpackTask

createRelease.dependsOn "assemble${os}Dist"
}

distributions {
mac {
contents {
into 'TerasologyLauncher.app/Contents'
exclude '**/*.bat'
eachFile { details ->
details.path = details.path.toString().replaceAll("(Contents)/bin/(.+)", "\$1/MacOS/\$2")
}
}
}
}

/**
Expand Down
Binary file removed src/dist/TerasologyLauncher.exe
Binary file not shown.

0 comments on commit 7713ecb

Please sign in to comment.