forked from MovingBlocks/TerasologyLauncher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundles.gradle
93 lines (84 loc) · 2.82 KB
/
bundles.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* Copyright 2016 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
enum Bundle {
win32,
win64,
linux32,
linux64,
macosx;
File jreArchive
}
task buildBundles {}
task unzipBundle(type: Copy) {
destinationDir buildDir
from (zipTree("${projectDir}/build/distributions/TerasologyLauncher.zip"))
}
def launcherDir = "${buildDir}/TerasologyLauncher/"
Bundle.each { arch ->
arch.jreArchive = new File("${projectDir}/jres/${arch}.zip")
def zipBase = ""
// Rebase everything in the zip file for MacOS X
if (arch == Bundle.macosx) {
zipBase = "TerasologyLauncher.app/Contents/Resources/"
}
def buildBundleTask = task("zip" + arch.name().capitalize(), type: Zip) {
dependsOn unzipBundle
archiveName "TerasologyLauncher-${arch}.zip"
destinationDir new File("${buildDir}/bundles/")
from(zipTree(arch.jreArchive)) {
into "${zipBase}jre"
}
from(launcherDir) {
// Platform independent files
exclude "*.exe"
exclude "bin"
into zipBase
}
/*
Copy only the files relevant to the platform we are bundling the JRE for.
I.e only copy 32-bit natives for windows if we bundle the 32-bit JRE.
*/
if (arch == Bundle.win32) {
from (launcherDir) {
include "TerasologyLauncher.x86.exe"
rename { "TerasologyLauncher.exe" }
}
} else if (arch == Bundle.win64) {
from (launcherDir) {
include "TerasologyLauncher.x64.exe"
rename { "TerasologyLauncher.exe" }
}
} else if (arch == Bundle.linux32) {
from ("bundles/linux") {
include "run_linux.sh"
rename { "terasology_launcher.sh" }
fileMode 755
}
} else if (arch == Bundle.linux64) {
from ("bundles/launchers") {
include "run_linux.sh"
rename { "terasology_launcher.sh" }
fileMode 755
}
} else if (arch == Bundle.macosx) {
from ("bundles/macosx") {
include "**/*"
into "TerasologyLauncher.app/Contents"
}
}
}
buildBundles.dependsOn buildBundleTask
}