forked from yairm210/Unciv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
149 lines (123 loc) · 4.53 KB
/
build.gradle.kts
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import com.badlogicgames.packr.Packr
import com.badlogicgames.packr.PackrConfig
import com.unciv.build.BuildConfig
import groovy.util.Node
import groovy.util.XmlNodePrinter
import groovy.util.XmlParser
import java.io.FileWriter
import java.io.PrintWriter
plugins {
id("kotlin")
}
java {
sourceCompatibility = JavaVersion.VERSION_1_6
}
sourceSets {
main {
java.srcDir("src/")
}
}
val mainClassName = "com.unciv.app.desktop.DesktopLauncher"
val assetsDir = file("../android/assets")
val discordDir = file("discord_rpc")
val deployFolder = file("../deploy")
tasks.register<JavaExec>("run") {
dependsOn(tasks.getByName("classes"))
main = mainClassName
classpath = sourceSets.main.get().runtimeClasspath
standardInput = System.`in`
workingDir = assetsDir
isIgnoreExitValue = true
}
tasks.register<JavaExec>("debug") {
dependsOn(tasks.getByName("classes"))
main = mainClassName
classpath = sourceSets.main.get().runtimeClasspath
standardInput = System.`in`
workingDir = assetsDir
isIgnoreExitValue = true
debug = true
}
tasks.register<Jar>("dist") { // Compiles the jar file
dependsOn(tasks.getByName("classes"))
from(files(sourceSets.main.get().output.resourcesDir))
from(files(sourceSets.main.get().output.classesDirs))
// see Laurent1967's comment on https://github.com/libgdx/libgdx/issues/5491
from({configurations.compileClasspath.get().resolve().map { if(it.isDirectory) it else zipTree(it) }})
from(files(assetsDir))
// This is for the .dll and .so files to make the Discord RPC work on all desktops
from(files(discordDir))
archiveName = "${BuildConfig.appName}.jar"
manifest {
attributes(mapOf("Main-Class" to mainClassName, "Specification-Version" to BuildConfig.appVersion))
}
}
for(platform in PackrConfig.Platform.values()) {
val platformName = platform.toString()
tasks.create("packr${platformName}") {
dependsOn(tasks.getByName("dist"))
val jarFile = "desktop/build/libs/${BuildConfig.appName}.jar"
val config = PackrConfig()
config.platform = platform
val forTravis = true // change to false for local build
if(forTravis) {
if (platform == PackrConfig.Platform.Linux32 || platform == PackrConfig.Platform.Linux64)
config.jdk = System.getenv("JAVA_HOME")
// take the jdk straight from the building linux computer
if (platform == PackrConfig.Platform.Windows64)
config.jdk = "jdk-windows-64.zip" // see how we download and name this in travis yml
if (platform == PackrConfig.Platform.Windows32)
config.jdk = "jdk-windows-32.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.apply {
executable = "Unciv"
classpath = listOf(jarFile)
removePlatformLibs = config.classpath
mainClass = mainClassName
vmArgs = listOf("Xmx1G")
minimizeJre = "desktop/packrConfig.json"
outDir = file("packr")
}
doLast {
if(config.outDir.exists()) delete(config.outDir)
Packr().pack(config)
}
tasks.register<Zip>("zip${platformName}") {
archiveName = "${BuildConfig.appName}-${platformName}.zip"
from(config.outDir)
destinationDir = deployFolder
}
finalizedBy("zip${platformName}")
}
}
tasks.register<Zip>("zipLinuxFilesForJar") {
archiveName = "linuxFilesForJar.zip"
from(file("linuxFilesForJar"))
destinationDir = deployFolder
}
tasks.register("packr") {
for(platform in PackrConfig.Platform.values())
finalizedBy("packr${platform.toString()}")
}
eclipse {
project {
name = "${BuildConfig.appName}-desktop"
linkedResource(mapOf("name" to "assets", "type" to "2", "location" to "PARENT-1-PROJECT_LOC/android/assets"))
}
}
tasks.register("afterEclipseImport") {
description = "Post processing after project generation"
group = "IDE"
doLast {
val classpath = XmlParser().parse(file(".classpath"))
Node(classpath, "classpathentry", mapOf("kind" to "src", "path" to "assets"))
val writer = FileWriter(file(".classpath"))
val printer = XmlNodePrinter(PrintWriter(writer))
printer.isPreserveWhitespace = true
printer.print(classpath)
}
}