Skip to content

Commit 42e3ede

Browse files
committed
New gradle task to build a distribution with downloaded JREs
1 parent 427ca94 commit 42e3ede

File tree

3 files changed

+111
-1
lines changed

3 files changed

+111
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,6 @@ engine/src/main/resources/settings.ini
7474
engine/src/main/resources/mercenaries.json
7575
engine/src/main/resources/world.ini
7676
engine/src/main/resources/world.json
77+
78+
# Ignore donwloaded JREs
79+
jre/**

config/gradle/jre.gradle

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright 2020 The Terasology Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Uses Bellsoft Liberica JRE
18+
def jreVersion = '8u212'
19+
def jreUrlBase = "https://download.bell-sw.com/java/$jreVersion/bellsoft-jre$jreVersion"
20+
def jreUrlFilenames = [
21+
lwjreLinux64 : 'linux-amd64.tar.gz',
22+
lwjreLinux : 'linux-i586.tar.gz',
23+
lwjre : 'windows-i586.zip',
24+
lwjreOSX : 'macos-amd64.zip'
25+
]
26+
27+
task downloadJreAll {
28+
group 'Download'
29+
description 'Downloads JRE for all platforms'
30+
}
31+
32+
jreUrlFilenames.each { os, file ->
33+
def packedJre = new File("$rootDir/jre/$jreVersion/$file")
34+
def unpackedJre = new File("$distsDir/app/$os")
35+
36+
def downloadTask = task("downloadJre$os") {
37+
group 'Download'
38+
description "Downloads JRE for $os"
39+
40+
doFirst {
41+
download {
42+
src "$jreUrlBase-$file"
43+
dest packedJre
44+
overwrite false
45+
}
46+
}
47+
48+
doLast {
49+
// Unpack the JRE
50+
if (!unpackedJre.exists()) {
51+
unpackedJre.mkdirs()
52+
copy {
53+
from(file.endsWith("zip")
54+
? zipTree(packedJre)
55+
: tarTree(packedJre)) {
56+
eachFile { fcd ->
57+
fcd.relativePath = new RelativePath(
58+
true, fcd.relativePath.segments.drop(1))
59+
}
60+
includeEmptyDirs = false
61+
}
62+
into unpackedJre
63+
}
64+
}
65+
}
66+
}
67+
68+
downloadJreAll.dependsOn downloadTask
69+
}
70+
71+

desktop/build.gradle

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1+
/*
2+
* Copyright 2020 The Terasology Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
id 'de.undercouch.download' version '4.0.4'
19+
}
20+
121
apply from: '../config/gradle/common.gradle'
22+
apply from: "../config/gradle/jre.gradle"
223

324
project.ext.mainClassName = "org.destinationsol.desktop.SolDesktop"
425

@@ -104,14 +125,29 @@ task distUnbundledJRE() {
104125
distUnbundledJRE.finalizedBy libsDist
105126
distUnbundledJRE.finalizedBy moduleDist
106127

107-
task distUnbundledJREZip(type: Zip) {
128+
task distZipUnbundledJRE(type: Zip) {
108129
description = "Creates an application package and zip archive without any bundled JRE."
109130

110131
dependsOn distUnbundledJRE
111132
from "$distsDir/app"
112133
archiveName = "DestinationSol.zip"
113134
}
114135

136+
task distBundleJREs {
137+
description = "Creates an application package with a bundled JRE."
138+
139+
dependsOn distUnbundledJRE
140+
dependsOn downloadJreAll
141+
}
142+
143+
task distZipBundleJREs (type: Zip) {
144+
description = "Creates an application package and zip archive with a bundled JRE."
145+
146+
dependsOn distBundleJREs
147+
from "$distsDir/app"
148+
archiveName = "DestinationSol.zip"
149+
}
150+
115151
// TODO: LibGDX Generated config for Eclipse. Needs adjustment for assets not being in the Android facade
116152
eclipse {
117153
project {

0 commit comments

Comments
 (0)