2019-08-22 02:41:38 +07:00
|
|
|
import com.badlogicgames.packr.Packr
|
|
|
|
import com.badlogicgames.packr.PackrConfig
|
|
|
|
|
2017-04-30 08:25:59 +07:00
|
|
|
apply plugin: "java"
|
|
|
|
|
|
|
|
sourceCompatibility = 1.8
|
2019-08-22 02:41:38 +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-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-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
|
2019-08-22 02:41:38 +07:00
|
|
|
ignoreExitValue = true
|
|
|
|
|
2018-04-28 09:44:21 +07:00
|
|
|
if(System.getProperty("os.name").toLowerCase().contains("mac")){
|
2019-08-22 02:41:38 +07:00
|
|
|
jvmArgs("-XstartOnFirstThread", "-Djava.awt.headless=true")
|
2018-04-28 09:44:21 +07:00
|
|
|
}
|
2019-08-22 02:41:38 +07:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-08-22 02:41:38 +07:00
|
|
|
["Windows", "Linux", "Mac", "All"].each{ target ->
|
|
|
|
task "dist$target"(type: Jar, dependsOn: classes){
|
|
|
|
from files(sourceSets.main.output.classesDirs)
|
|
|
|
from files(sourceSets.main.output.resourcesDir)
|
|
|
|
from {configurations.compile.collect {zipTree(it)}}
|
|
|
|
from files(project.assetsDir)
|
2018-12-14 06:01:51 +07:00
|
|
|
|
2019-08-22 02:41:38 +07:00
|
|
|
if(target.contains("windows")) exclude('**.so', "**.dylib")
|
|
|
|
if(target == "mac") exclude('**.so', "**.dll")
|
|
|
|
if(target == "linux") exclude('**.dll', "**.dylib")
|
|
|
|
archiveName = "$appName-${target}.jar"
|
2018-02-09 11:41:07 +07:00
|
|
|
|
2019-08-22 02:41:38 +07:00
|
|
|
manifest{
|
|
|
|
attributes 'Main-Class': project.mainClassName
|
|
|
|
}
|
2017-04-30 08:25:59 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-22 01:46:36 +07:00
|
|
|
PackrConfig.Platform.values().each{ platform ->
|
|
|
|
task "packr${platform.toString()}"{
|
2019-08-22 02:41:38 +07:00
|
|
|
def platformName = platform.toString().replace('64', '').replace('32', '').replace('MacOS', 'Mac')
|
|
|
|
|
|
|
|
dependsOn "dist$platformName"
|
|
|
|
|
2019-03-10 07:43:33 +07:00
|
|
|
doLast{
|
2019-08-22 02:41:38 +07:00
|
|
|
copy{
|
|
|
|
into "build/packr/"
|
|
|
|
rename("$appName-${platformName}.jar", "desktop.jar")
|
|
|
|
from "build/libs/$appName-${platformName}.jar"
|
|
|
|
}
|
|
|
|
|
|
|
|
delete{
|
|
|
|
delete "build/packr/output/"
|
|
|
|
}
|
|
|
|
|
2019-08-22 01:46:36 +07:00
|
|
|
if(platform == PackrConfig.Platform.Windows32 || platform == PackrConfig.Platform.Windows64){
|
|
|
|
copy{
|
2019-08-22 02:41:38 +07:00
|
|
|
into "build/packr/output"
|
2019-08-22 01:46:36 +07:00
|
|
|
from "${JDK_DIR}/templates/${platform.toString().toLowerCase()}"
|
|
|
|
}
|
|
|
|
|
|
|
|
copy{
|
2019-08-22 02:41:38 +07:00
|
|
|
into "build/packr/output/jre"
|
|
|
|
rename("$appName-${platformName}.jar", "desktop.jar")
|
|
|
|
from "build/libs/$appName-${platformName}.jar"
|
2019-08-22 01:46:36 +07:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
def config = new PackrConfig()
|
|
|
|
config.with{
|
|
|
|
config.executable = appName
|
|
|
|
config.platform = platform
|
|
|
|
verbose = true
|
|
|
|
bundleIdentifier = getPackage() + ".mac"
|
|
|
|
iconResource = ICON_DIR
|
2019-08-22 02:41:38 +07:00
|
|
|
outDir = file("build/packr/output")
|
2019-08-22 01:46:36 +07:00
|
|
|
mainClass = project.ext.mainClassName
|
2019-08-22 02:41:38 +07:00
|
|
|
classpath = ["desktop/build/packr/desktop.jar"]
|
|
|
|
removePlatformLibs = ["desktop/build/packr/desktop.jar"]
|
2019-08-22 01:46:36 +07:00
|
|
|
|
|
|
|
vmArgs = ["Djava.net.preferIPv4Stack=true"]
|
|
|
|
minimizeJre = "desktop/packr_minimize.json"
|
|
|
|
jdk = JDK_DIR + "jdk-${platform.toString().toLowerCase()}.zip"
|
|
|
|
|
|
|
|
if(platform == PackrConfig.Platform.MacOS){
|
|
|
|
vmArgs += "XstartOnFirstThread"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
new Packr().pack(config)
|
|
|
|
|
2019-08-22 02:41:38 +07:00
|
|
|
if(platform == PackrConfig.Platform.Linux64){
|
2019-08-22 01:46:36 +07:00
|
|
|
copy{
|
2019-08-22 02:41:38 +07:00
|
|
|
into "build/packr/output/jre/"
|
|
|
|
from "build/packr/output/desktop.jar"
|
2019-08-22 01:46:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
delete{
|
2019-08-22 02:41:38 +07:00
|
|
|
delete "build/packr/output/desktop.jar"
|
2019-08-22 01:46:36 +07:00
|
|
|
}
|
2019-08-22 02:41:38 +07:00
|
|
|
|
|
|
|
file("build/packr/output/config.json").text = file("build/packr/output/config.json").text.replace("desktop.jar", "jre/desktop.jar")
|
2019-08-22 01:46:36 +07:00
|
|
|
}
|
2017-12-29 03:26:11 +07:00
|
|
|
|
2019-08-22 02:41:38 +07:00
|
|
|
if(platform == PackrConfig.Platform.MacOS){
|
|
|
|
copy{
|
|
|
|
into "build/packr/${appName}.app/Contents/"
|
|
|
|
from "build/packr/Contents/"
|
|
|
|
}
|
|
|
|
|
|
|
|
delete{
|
|
|
|
delete "build/packr/Contents/"
|
|
|
|
}
|
|
|
|
}
|
2019-03-23 09:30:26 +07:00
|
|
|
}
|
2019-08-22 02:41:38 +07:00
|
|
|
}
|
2017-12-29 03:26:11 +07:00
|
|
|
|
2019-08-22 02:41:38 +07:00
|
|
|
task "zip${platform.toString()}"(type: Zip){
|
|
|
|
from "build/packr/output"
|
|
|
|
archiveName "${generateDeployName(platform.toString())}.zip"
|
|
|
|
destinationDir(file("../deploy"))
|
2018-02-01 04:05:43 +07:00
|
|
|
|
2019-08-22 02:41:38 +07:00
|
|
|
doLast{
|
|
|
|
delete{
|
|
|
|
delete "build/packr/"
|
|
|
|
}
|
|
|
|
}
|
2018-02-01 04:05:43 +07:00
|
|
|
}
|
2019-08-22 02:41:38 +07:00
|
|
|
|
|
|
|
finalizedBy "zip${platform.toString()}"
|
2018-02-01 04:05:43 +07:00
|
|
|
}
|
2019-08-22 01:46:36 +07:00
|
|
|
}
|