2019-11-23 22:02:28 +00:00
|
|
|
import com.badlogicgames.packr.Packr
|
|
|
|
import com.badlogicgames.packr.PackrConfig
|
|
|
|
|
2018-02-23 13:36:13 +00:00
|
|
|
apply plugin: "kotlin"
|
2017-11-21 22:09:35 +00:00
|
|
|
|
|
|
|
sourceCompatibility = 1.6
|
|
|
|
sourceSets.main.java.srcDirs = [ "src/" ]
|
|
|
|
|
2019-11-14 21:54:52 +00:00
|
|
|
project.ext.mainClassName = "com.unciv.app.desktop.DesktopLauncher"
|
2019-11-27 18:16:53 +00:00
|
|
|
project.ext.assetsDir = file("../android/assets")
|
|
|
|
project.ext.discordDir = file("discord_rpc")
|
2019-11-27 19:03:14 +00:00
|
|
|
def deployFolder = file("../deploy")
|
2017-11-21 22:09:35 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-11-25 04:34:02 +00:00
|
|
|
task dist(dependsOn: classes, type: Jar) { // Compiles the jar file
|
2017-11-21 22:09:35 +00:00
|
|
|
from files(sourceSets.main.output.resourcesDir)
|
2019-11-11 21:17:12 +00:00
|
|
|
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) }}
|
2018-02-23 10:57:52 +00:00
|
|
|
from files(project.assetsDir)
|
2019-11-21 21:01:38 +00:00
|
|
|
// This is for the .dll and .so files to ake the Discord RPC work on all desktops
|
|
|
|
from files(project.discordDir)
|
2019-11-15 07:27:13 +00:00
|
|
|
archiveFileName = "${appName}.jar"
|
2017-11-21 22:09:35 +00:00
|
|
|
|
|
|
|
manifest {
|
|
|
|
attributes 'Main-Class': project.mainClassName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-24 20:22:47 +00:00
|
|
|
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
|
2019-11-26 21:11:00 +00:00
|
|
|
|
2019-12-31 15:49:07 +00:00
|
|
|
def forTravis = true // change to false for local build
|
|
|
|
if(forTravis) {
|
2019-11-27 18:16:53 +00:00
|
|
|
if (platform == PackrConfig.Platform.Linux32 || platform == PackrConfig.Platform.Linux64)
|
|
|
|
config.jdk = System.env.'JAVA_HOME'
|
|
|
|
// take the jdk straight from the building linux computer
|
2019-11-26 21:11:00 +00:00
|
|
|
|
2019-11-27 18:16:53 +00:00
|
|
|
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"
|
|
|
|
}
|
2019-11-24 20:22:47 +00:00
|
|
|
config.executable = "Unciv"
|
|
|
|
config.classpath = Arrays.asList(jarFile)
|
|
|
|
config.removePlatformLibs = config.classpath
|
|
|
|
config.mainClass = project.ext.mainClassName
|
|
|
|
config.vmArgs = Arrays.asList("Xmx1G")
|
2019-11-27 18:16:53 +00:00
|
|
|
config.minimizeJre = "desktop/packrConfig.json"
|
2019-11-24 20:22:47 +00:00
|
|
|
config.outDir = file("packr")
|
|
|
|
|
|
|
|
doLast {
|
2019-11-24 20:50:58 +00:00
|
|
|
if(config.outDir.exists()) delete(config.outDir)
|
2019-11-24 20:22:47 +00:00
|
|
|
new Packr().pack(config)
|
|
|
|
}
|
|
|
|
|
|
|
|
task "zip${platformName}"(type: Zip) {
|
|
|
|
archiveFileName = "${appName}-${platformName}.zip"
|
|
|
|
from config.outDir
|
|
|
|
destinationDirectory = deployFolder
|
|
|
|
}
|
|
|
|
|
|
|
|
finalizedBy "zip${platformName}"
|
|
|
|
}
|
2019-11-23 22:02:28 +00:00
|
|
|
}
|
2017-11-21 22:09:35 +00:00
|
|
|
|
2019-11-27 19:03:14 +00:00
|
|
|
task zipLinuxFilesForJar(type: Zip) {
|
|
|
|
archiveFileName = "linuxFilesForJar.zip"
|
|
|
|
from file("linuxFilesForJar")
|
|
|
|
destinationDirectory = deployFolder
|
|
|
|
}
|
|
|
|
|
2019-11-24 20:22:47 +00:00
|
|
|
task packr(){
|
|
|
|
for(platform in PackrConfig.Platform.values())
|
|
|
|
finalizedBy "packr${platform.toString()}"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-21 22:09:35 +00:00
|
|
|
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"))
|
2018-02-23 10:57:52 +00:00
|
|
|
new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ])
|
2017-11-21 22:09:35 +00:00
|
|
|
def writer = new FileWriter(file(".classpath"))
|
|
|
|
def printer = new XmlNodePrinter(new PrintWriter(writer))
|
|
|
|
printer.setPreserveWhitespace(true)
|
|
|
|
printer.print(classpath)
|
|
|
|
}
|
2019-11-24 06:05:04 +00:00
|
|
|
}
|