108 lines
3.7 KiB
Groovy
108 lines
3.7 KiB
Groovy
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 = new File("../android/assets")
|
|
project.ext.discordDir = new File("discord_rpc")
|
|
|
|
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
|
|
config.jdk = System.env.'JAVA_HOME' // For Travis
|
|
// 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")
|
|
// configuration comprised from 3 sources:
|
|
// https://github.com/libgdx/packr/blob/master/src/main/resources/minimize/hard
|
|
// https://github.com/libgdx/packr/blob/master/src/main/resources/minimize/oraclejre8
|
|
// And Mindustry,
|
|
// and added a few touches of my own.
|
|
// Down from ~80MB to ~50MB!
|
|
config.minimizeJre = "desktop/packrConfig.json"
|
|
config.outDir = file("packr")
|
|
config.cacheJre=file("packrCache")
|
|
|
|
doLast {
|
|
if(config.outDir.exists()) delete(config.outDir)
|
|
new Packr().pack(config)
|
|
}
|
|
|
|
task "zip${platformName}"(type: Zip) {
|
|
def deployFolder = file("../deploy")
|
|
archiveFileName = "${appName}-${platformName}.zip"
|
|
from config.outDir
|
|
destinationDirectory = deployFolder
|
|
}
|
|
|
|
finalizedBy "zip${platformName}"
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|