forked from yairm210/Unciv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
119 lines (99 loc) · 3.95 KB
/
build.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import com.badlogicgames.packr.Packr
import com.badlogicgames.packr.PackrConfig
apply plugin: "kotlin"
sourceCompatibility = 1.6
sourceSets.main.java.srcDirs = [ "src/" ]
project.ext.mainClassName = "com.unciv.app.desktop.DesktopLauncher"
project.ext.assetsDir = file("../android/assets")
project.ext.discordDir = file("discord_rpc")
def deployFolder = file("../deploy")
task run(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}
task debug(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
debug = true
}
task dist(dependsOn: classes, type: Jar) { // Compiles the jar file
from files(sourceSets.main.output.resourcesDir)
from files(sourceSets.main.output.classesDirs)
// see Laurent1967's comment on https://github.com/libgdx/libgdx/issues/5491
from {configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }}
from files(project.assetsDir)
// This is for the .dll and .so files to ake the Discord RPC work on all desktops
from files(project.discordDir)
archiveFileName = "${appName}.jar"
manifest {
attributes 'Main-Class': project.mainClassName
}
}
for(platform in PackrConfig.Platform.values()) {
def platformName = platform.toString()
task "packr${platformName}"(dependsOn: dist) {
def jarFile = "desktop/build/libs/${appName}.jar".toString()
PackrConfig config = new PackrConfig()
config.platform = platform
def forTravis = true // change to false for local build
if(forTravis) {
if (platform == PackrConfig.Platform.Linux32 || platform == PackrConfig.Platform.Linux64)
config.jdk = System.env.'JAVA_HOME'
// take the jdk straight from the building linux computer
if (platform == PackrConfig.Platform.Windows32 || platform == PackrConfig.Platform.Windows64)
config.jdk = "jdk-windows.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.executable = "Unciv"
config.classpath = Arrays.asList(jarFile)
config.removePlatformLibs = config.classpath
config.mainClass = project.ext.mainClassName
config.vmArgs = Arrays.asList("Xmx1G")
config.minimizeJre = "desktop/packrConfig.json"
config.outDir = file("packr")
doLast {
if(config.outDir.exists()) delete(config.outDir)
new Packr().pack(config)
}
task "zip${platformName}"(type: Zip) {
archiveFileName = "${appName}-${platformName}.zip"
from config.outDir
destinationDirectory = deployFolder
}
finalizedBy "zip${platformName}"
}
}
task zipLinuxFilesForJar(type: Zip) {
archiveFileName = "linuxFilesForJar.zip"
from file("linuxFilesForJar")
destinationDirectory = deployFolder
}
task packr(){
for(platform in PackrConfig.Platform.values())
finalizedBy "packr${platform.toString()}"
}
eclipse {
project {
name = appName + "-desktop"
linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/android/assets'
}
}
task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
doLast {
def classpath = new XmlParser().parse(file(".classpath"))
new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ])
def writer = new FileWriter(file(".classpath"))
def printer = new XmlNodePrinter(new PrintWriter(writer))
printer.setPreserveWhitespace(true)
printer.print(classpath)
}
}