Mindustry/desktop/build.gradle

158 lines
3.9 KiB
Groovy
Raw Normal View History

2017-04-30 08:25:59 +07:00
apply plugin: "java"
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = ["src/"]
2017-04-30 08:25:59 +07:00
2017-05-03 11:09:48 +07:00
project.ext.mainClassName = "io.anuke.mindustry.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../core/assets")
def PACKR_DIR = "$System.env.PACKR_DIR"
def ICON_DIR = new File("core/assets/sprites/icon.icns")
2017-04-30 08:25:59 +07:00
ext.getPlatform = {
if(project.hasProperty("platform")){
def lc = platform.toLowerCase()
if(lc == "windows64"){
return "windows64"
}else if(lc == "windows32"){
return "windows32"
}else if(lc == "linux"){
return "linux64"
}else if(lc == "mac"){
return "mac"
}else{
throw new InvalidUserDataException("Invalid platform. Set platform with -Pplatform=windows/linux/mac")
}
}else{
throw new InvalidUserDataException("No platform defined. Set platform with -Pplatform=windows/linux/mac")
}
}
task run(dependsOn: classes, type: JavaExec){
2017-04-30 08:25:59 +07:00
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
if(System.getProperty("os.name").toLowerCase().contains("mac")){
jvmArgs "-XstartOnFirstThread"
}
2017-04-30 08:25:59 +07:00
ignoreExitValue = true
if(project.hasProperty("args")){
2018-09-11 06:33:12 +07:00
args Eval.me(project.getProperties()["args"])
}
if(args.contains("debug")){
main = "io.anuke.mindustry.DebugLauncher"
2017-12-22 08:59:40 +07:00
}
2017-04-30 08:25:59 +07:00
}
task debug(dependsOn: classes, type: JavaExec){
2017-04-30 08:25:59 +07:00
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
debug = true
}
task dist(type: Jar){
dependsOn classes
writeVersion()
2018-02-02 10:16:00 +07:00
from files(sourceSets.main.output.classesDirs)
2017-04-30 08:25:59 +07:00
from files(sourceSets.main.output.resourcesDir)
from{ configurations.compile.collect{ zipTree(it) } }
from files(project.assetsDir)
manifest{
2017-04-30 08:25:59 +07:00
attributes 'Main-Class': project.mainClassName
}
}
task clearOut(type: Delete){
doLast{
delete "packr-out/"
}
}
//note: call desktop:dist beforehand
task packrCmd(){
doLast{
copy{
into PACKR_DIR
from "build/libs/desktop-release.jar"
}
exec{
commandLine("java", "-jar", PACKR_DIR + "packr.jar",
"--verbose",
2018-05-25 03:12:12 +07:00
"--bundle", getPackage() + ".mac",
"--platform", getPlatform(),
"--executable", appName,
"--output", "packr-out/",
"--mainclass", project.ext.mainClassName,
"--jdk", PACKR_DIR + "jdk-" + getPlatform() + ".zip",
"--icon", ICON_DIR.getAbsolutePath(),
2018-10-06 22:56:39 +07:00
"--vmargs", (getPlatform() == "mac" ? "XstartOnFirstThread" : "Xms256m"),
2018-09-26 10:27:19 +07:00
"Djava.net.preferIPv4Stack=true",
"--classpath", "--", PACKR_DIR + "config.json")
}
}
}
task fixMac(type: Copy){
dependsOn "packrCmd"
into "packr-out/" + appName + ".app/Contents/"
from "packr-out/Contents/"
doLast{
delete{
delete "packr-out/Contents/"
}
}
}
task fixWindows32(type: Copy){
dependsOn "packrCmd"
into "packr-out/jre/bin/"
from PACKR_DIR + "zip.dll"
rename("zip.dll", "ojdkbuild_zlib.dll")
doLast{
copy{
into "packr-out/jre/bin/"
from PACKR_DIR + "zip.dll"
}
}
}
task packrZip(){
dependsOn "packrCmd"
finalizedBy "clearOut"
if(project.hasProperty("platform")){
if(getPlatform() == "mac"){
dependsOn "fixMac"
}
if(getPlatform() == "windows32"){
dependsOn "fixWindows32"
}
2018-02-01 04:05:43 +07:00
task zip(type: Zip){
from "packr-out/"
archiveName "$appName-${getPlatform()}-${getVersionString()}.zip"
destinationDir(file("packr-export"))
2018-02-01 04:05:43 +07:00
}
finalizedBy 'zip'
2018-02-01 04:05:43 +07:00
}
}