2017-04-30 08:25:59 +07:00
|
|
|
apply plugin: "java"
|
|
|
|
|
|
|
|
sourceCompatibility = 1.8
|
2018-12-14 06:01:51 +07:00
|
|
|
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"
|
2018-02-09 11:41:07 +07:00
|
|
|
project.ext.assetsDir = new File("../core/assets")
|
2017-08-09 07:18:31 +07:00
|
|
|
|
2019-07-25 21:09:21 +07:00
|
|
|
def IKVM_DIR = System.env.IKVM_HOME
|
2019-04-08 20:03:18 +07:00
|
|
|
|
2019-03-10 07:12:54 +07:00
|
|
|
import com.badlogicgames.packr.Packr
|
2019-04-08 20:03:18 +07:00
|
|
|
import com.badlogicgames.packr.PackrConfig
|
2019-03-10 07:12:54 +07:00
|
|
|
|
|
|
|
def JDK_DIR = "$System.env.PACKR_DIR"
|
2019-07-12 12:03:01 +07:00
|
|
|
def ICON_DIR = new File("core/assets/icons/icon.icns")
|
2017-04-30 08:25:59 +07:00
|
|
|
|
2018-02-09 11:41:07 +07:00
|
|
|
ext.getPlatform = {
|
2019-03-10 07:12:54 +07:00
|
|
|
def lc = project.hasProperty("platform") ? platform.toLowerCase() : ""
|
|
|
|
if(lc == "windows64"){
|
|
|
|
return PackrConfig.Platform.Windows64
|
|
|
|
}else if(lc == "windows32"){
|
|
|
|
return PackrConfig.Platform.Windows32
|
|
|
|
}else if(lc == "linux"){
|
|
|
|
return PackrConfig.Platform.Linux64
|
|
|
|
}else if(lc == "mac"){
|
|
|
|
return PackrConfig.Platform.MacOS
|
2018-12-14 06:01:51 +07:00
|
|
|
}else{
|
2019-03-10 07:12:54 +07:00
|
|
|
throw new InvalidUserDataException("Invalid platform. Set platform with -Pplatform=windows64/windows32/linux/mac")
|
2018-02-09 11:41:07 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-14 06:01:51 +07:00
|
|
|
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
|
2018-04-28 09:44:21 +07:00
|
|
|
if(System.getProperty("os.name").toLowerCase().contains("mac")){
|
|
|
|
jvmArgs "-XstartOnFirstThread"
|
|
|
|
}
|
2017-04-30 08:25:59 +07:00
|
|
|
ignoreExitValue = true
|
2018-12-14 06:01:51 +07:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-12-14 06:01:51 +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
|
|
|
|
}
|
|
|
|
|
2018-12-14 06:01:51 +07:00
|
|
|
task dist(type: Jar){
|
2018-02-09 11:41:07 +07:00
|
|
|
dependsOn classes
|
2018-12-14 06:01:51 +07:00
|
|
|
|
2018-02-09 11:41:07 +07:00
|
|
|
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)
|
2018-12-14 06:01:51 +07:00
|
|
|
from{ configurations.compile.collect{ zipTree(it) } }
|
2018-02-09 11:41:07 +07:00
|
|
|
from files(project.assetsDir)
|
|
|
|
|
2018-12-14 06:01:51 +07:00
|
|
|
manifest{
|
2017-04-30 08:25:59 +07:00
|
|
|
attributes 'Main-Class': project.mainClassName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-09 11:41:07 +07:00
|
|
|
//note: call desktop:dist beforehand
|
2018-12-14 06:01:51 +07:00
|
|
|
task packrCmd(){
|
2018-01-23 00:46:00 +07:00
|
|
|
|
2018-12-14 06:01:51 +07:00
|
|
|
doLast{
|
2019-03-10 07:12:54 +07:00
|
|
|
def config = new PackrConfig()
|
|
|
|
config.with{
|
|
|
|
config.executable = appName
|
|
|
|
verbose = true
|
|
|
|
platform = getPlatform()
|
|
|
|
bundleIdentifier = getPackage() + ".mac"
|
|
|
|
iconResource = ICON_DIR
|
|
|
|
outDir = file("packr-out/")
|
|
|
|
mainClass = project.ext.mainClassName
|
|
|
|
classpath = ["desktop/build/libs/desktop-release.jar"]
|
2019-03-21 22:15:03 +07:00
|
|
|
removePlatformLibs = ["desktop/build/libs/desktop-release.jar"]
|
|
|
|
|
2019-03-10 07:12:54 +07:00
|
|
|
vmArgs = ["Djava.net.preferIPv4Stack=true"]
|
|
|
|
minimizeJre = "desktop/packr_minimize.json"
|
|
|
|
jdk = JDK_DIR + "jdk-${getPlatform().toString().toLowerCase()}.zip"
|
|
|
|
|
|
|
|
if(getPlatform() == PackrConfig.Platform.MacOS){
|
|
|
|
vmArgs += "XstartOnFirstThread"
|
|
|
|
}
|
2018-02-09 11:41:07 +07:00
|
|
|
}
|
2017-12-29 03:26:11 +07:00
|
|
|
|
2019-03-10 07:12:54 +07:00
|
|
|
new Packr().pack(config)
|
2018-02-09 11:41:07 +07:00
|
|
|
}
|
2017-08-09 07:18:31 +07:00
|
|
|
}
|
|
|
|
|
2019-03-23 09:30:26 +07:00
|
|
|
task copyTemplate(){
|
|
|
|
doLast{
|
|
|
|
copy{
|
|
|
|
into "packr-out/"
|
|
|
|
from "${JDK_DIR}/templates/${getPlatform().toString().toLowerCase()}"
|
|
|
|
}
|
|
|
|
|
|
|
|
copy{
|
|
|
|
into "packr-out/"
|
|
|
|
from "build/libs/desktop-release.jar"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-10 07:43:33 +07:00
|
|
|
task packrZip(){
|
|
|
|
task clearOut(type: Delete){
|
|
|
|
doLast{
|
|
|
|
delete "packr-out/"
|
|
|
|
}
|
|
|
|
}
|
2017-12-29 03:26:11 +07:00
|
|
|
|
2019-03-10 07:43:33 +07:00
|
|
|
task fixMac(type: Copy){
|
|
|
|
dependsOn "packrCmd"
|
2017-12-29 03:26:11 +07:00
|
|
|
|
2019-03-10 07:43:33 +07:00
|
|
|
into "packr-out/" + appName + ".app/Contents/"
|
|
|
|
from "packr-out/Contents/"
|
|
|
|
|
|
|
|
doLast{
|
|
|
|
delete{
|
|
|
|
delete "packr-out/Contents/"
|
|
|
|
}
|
2017-12-29 03:26:11 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-10 07:43:33 +07:00
|
|
|
task fixWindows32(type: Copy){
|
|
|
|
dependsOn "packrCmd"
|
2017-12-29 03:26:11 +07:00
|
|
|
|
2019-03-10 07:43:33 +07:00
|
|
|
into "packr-out/jre/bin/"
|
|
|
|
from JDK_DIR + "zip.dll"
|
|
|
|
rename("zip.dll", "ojdkbuild_zlib.dll")
|
2017-12-29 03:26:11 +07:00
|
|
|
|
2019-03-10 07:43:33 +07:00
|
|
|
doLast{
|
|
|
|
copy{
|
|
|
|
into "packr-out/jre/bin/"
|
|
|
|
from JDK_DIR + "zip.dll"
|
|
|
|
}
|
2017-12-29 03:26:11 +07:00
|
|
|
}
|
|
|
|
}
|
2019-04-08 20:03:18 +07:00
|
|
|
|
2018-02-09 11:41:07 +07:00
|
|
|
finalizedBy "clearOut"
|
2017-12-29 03:26:11 +07:00
|
|
|
|
2018-12-14 06:01:51 +07:00
|
|
|
if(project.hasProperty("platform")){
|
2019-03-23 09:30:26 +07:00
|
|
|
def plat = getPlatform()
|
|
|
|
if(plat == PackrConfig.Platform.Windows32 || plat == PackrConfig.Platform.Windows64){
|
|
|
|
dependsOn "copyTemplate"
|
|
|
|
}else{
|
|
|
|
dependsOn "packrCmd"
|
2017-12-29 03:26:11 +07:00
|
|
|
|
2019-03-23 09:30:26 +07:00
|
|
|
if(getPlatform() == PackrConfig.Platform.MacOS){
|
|
|
|
dependsOn "fixMac"
|
|
|
|
}
|
2017-12-29 03:26:11 +07:00
|
|
|
|
2019-03-23 09:30:26 +07:00
|
|
|
if(getPlatform() == PackrConfig.Platform.Windows32){
|
|
|
|
dependsOn "fixWindows32"
|
|
|
|
}
|
2018-02-09 11:41:07 +07:00
|
|
|
}
|
2018-02-01 04:05:43 +07:00
|
|
|
|
2019-03-10 07:43:33 +07:00
|
|
|
task rzip(type: Zip){
|
2018-02-09 11:41:07 +07:00
|
|
|
from "packr-out/"
|
2019-08-16 22:00:15 +07:00
|
|
|
archiveName "${generateDeployName(getPlatform().toString())}.zip"
|
2018-02-09 11:41:07 +07:00
|
|
|
destinationDir(file("packr-export"))
|
2018-02-01 04:05:43 +07:00
|
|
|
}
|
2018-02-09 11:41:07 +07:00
|
|
|
|
2019-03-10 07:43:33 +07:00
|
|
|
finalizedBy 'rzip'
|
2018-02-01 04:05:43 +07:00
|
|
|
}
|
2019-07-25 21:14:01 +07:00
|
|
|
}
|