Skip to content

Commit 5e71d02

Browse files
authored
Merge pull request #479 from SimonC4/Download-JRE-During-Build
Download JRE During Build Distribution Task
2 parents d02817a + 42e3ede commit 5e71d02

File tree

3 files changed

+146
-0
lines changed

3 files changed

+146
-0
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: 72 additions & 0 deletions
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

@@ -76,6 +97,57 @@ task distZip(type: Zip) {
7697
archiveName = "DestinationSol.zip"
7798
}
7899

100+
task copyLaunchers (type: Copy) {
101+
description = "Copy launchers into the distribution folder."
102+
103+
from("$rootDir/launcher")
104+
include("*.sh", "*.exe")
105+
into("$distsDir/app")
106+
}
107+
108+
task libsDist(type: Copy) {
109+
description = "Copy libs directory into the distribution folder."
110+
111+
dependsOn jar
112+
113+
from jar
114+
from configurations.runtime
115+
into("$distsDir/app/libs")
116+
}
117+
118+
task distUnbundledJRE() {
119+
description = "Creates an application package without any bundled JRE."
120+
121+
dependsOn clean
122+
dependsOn jar
123+
dependsOn copyLaunchers
124+
}
125+
distUnbundledJRE.finalizedBy libsDist
126+
distUnbundledJRE.finalizedBy moduleDist
127+
128+
task distZipUnbundledJRE(type: Zip) {
129+
description = "Creates an application package and zip archive without any bundled JRE."
130+
131+
dependsOn distUnbundledJRE
132+
from "$distsDir/app"
133+
archiveName = "DestinationSol.zip"
134+
}
135+
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+
79151
// TODO: LibGDX Generated config for Eclipse. Needs adjustment for assets not being in the Android facade
80152
eclipse {
81153
project {

0 commit comments

Comments
 (0)