2019-08-21 15:41:38 -04:00
|
|
|
import com.badlogicgames.packr.Packr
|
|
|
|
import com.badlogicgames.packr.PackrConfig
|
|
|
|
|
2017-04-29 21:25:59 -04:00
|
|
|
apply plugin: "java"
|
|
|
|
|
|
|
|
sourceCompatibility = 1.8
|
2019-08-21 15:41:38 -04:00
|
|
|
sourceSets.main.java.srcDirs = [ "src/" ]
|
2017-04-29 21:25:59 -04:00
|
|
|
|
2017-05-03 00:09:48 -04:00
|
|
|
project.ext.mainClassName = "io.anuke.mindustry.desktop.DesktopLauncher"
|
2018-02-08 23:41:07 -05:00
|
|
|
project.ext.assetsDir = new File("../core/assets")
|
2017-08-08 20:18:31 -04:00
|
|
|
|
2019-08-24 18:29:21 -04:00
|
|
|
def enableTemplates = true
|
2019-03-09 19:12:54 -05:00
|
|
|
def JDK_DIR = "$System.env.PACKR_DIR"
|
2019-07-12 01:03:01 -04:00
|
|
|
def ICON_DIR = new File("core/assets/icons/icon.icns")
|
2017-04-29 21:25:59 -04:00
|
|
|
|
2018-12-13 18:01:51 -05:00
|
|
|
task run(dependsOn: classes, type: JavaExec){
|
2017-04-29 21:25:59 -04:00
|
|
|
main = project.mainClassName
|
|
|
|
classpath = sourceSets.main.runtimeClasspath
|
|
|
|
standardInput = System.in
|
|
|
|
workingDir = project.assetsDir
|
2019-08-21 15:41:38 -04:00
|
|
|
ignoreExitValue = true
|
|
|
|
|
2018-04-27 22:44:21 -04:00
|
|
|
if(System.getProperty("os.name").toLowerCase().contains("mac")){
|
2019-08-21 15:41:38 -04:00
|
|
|
jvmArgs("-XstartOnFirstThread", "-Djava.awt.headless=true")
|
2018-04-27 22:44:21 -04:00
|
|
|
}
|
2019-08-21 15:41:38 -04:00
|
|
|
|
2018-12-13 18:01:51 -05:00
|
|
|
if(project.hasProperty("args")){
|
2018-09-10 19:33:12 -04:00
|
|
|
args Eval.me(project.getProperties()["args"])
|
|
|
|
}
|
|
|
|
|
|
|
|
if(args.contains("debug")){
|
|
|
|
main = "io.anuke.mindustry.DebugLauncher"
|
2017-12-21 20:59:40 -05:00
|
|
|
}
|
2017-04-29 21:25:59 -04:00
|
|
|
}
|
|
|
|
|
2018-02-08 23:41:07 -05:00
|
|
|
|
2019-08-21 15:50:58 -04:00
|
|
|
task dist(type: Jar, dependsOn: classes){
|
2018-02-01 22:16:00 -05:00
|
|
|
from files(sourceSets.main.output.classesDirs)
|
2017-04-29 21:25:59 -04:00
|
|
|
from files(sourceSets.main.output.resourcesDir)
|
2019-08-21 15:50:58 -04:00
|
|
|
from {configurations.compile.collect {zipTree(it)}}
|
2018-02-08 23:41:07 -05:00
|
|
|
from files(project.assetsDir)
|
|
|
|
|
2019-08-21 15:50:58 -04:00
|
|
|
archiveName = "${appName}.jar"
|
|
|
|
|
2018-12-13 18:01:51 -05:00
|
|
|
manifest{
|
2017-04-29 21:25:59 -04:00
|
|
|
attributes 'Main-Class': project.mainClassName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-22 09:27:59 -04:00
|
|
|
task steamtest(dependsOn: dist){
|
2018-12-13 18:01:51 -05:00
|
|
|
doLast{
|
2019-08-21 20:10:54 -04:00
|
|
|
copy{
|
2019-08-22 16:13:39 -04:00
|
|
|
from "build/libs/Mindustry.jar"
|
|
|
|
if(System.properties["os.name"].contains("Mac")){
|
2019-08-22 16:19:29 -04:00
|
|
|
into "/Users/anuke/Library/Application Support/Steam/steamapps/common/Mindustry/Contents/Resources"
|
2019-08-22 16:13:39 -04:00
|
|
|
}else{
|
2019-08-22 16:44:32 -04:00
|
|
|
into "/home/anuke/.steam/steam/steamapps/common/Mindustry/jre"
|
2019-08-22 16:13:39 -04:00
|
|
|
}
|
2019-08-22 16:19:29 -04:00
|
|
|
rename("Mindustry.jar", "desktop.jar")
|
2018-02-08 23:41:07 -05:00
|
|
|
}
|
|
|
|
}
|
2017-08-08 20:18:31 -04:00
|
|
|
}
|
|
|
|
|
2019-08-21 14:46:36 -04:00
|
|
|
PackrConfig.Platform.values().each{ platform ->
|
|
|
|
task "packr${platform.toString()}"{
|
2019-08-21 15:50:58 -04:00
|
|
|
dependsOn dist
|
2019-03-22 22:30:26 -04:00
|
|
|
|
2019-03-09 19:43:33 -05:00
|
|
|
doLast{
|
2019-08-21 15:41:38 -04:00
|
|
|
copy{
|
|
|
|
into "build/packr/"
|
2019-08-21 15:50:58 -04:00
|
|
|
rename("${appName}.jar", "desktop.jar")
|
|
|
|
from "build/libs/${appName}.jar"
|
2019-08-21 15:41:38 -04:00
|
|
|
}
|
2019-03-09 19:43:33 -05:00
|
|
|
|
|
|
|
delete{
|
2019-08-21 15:41:38 -04:00
|
|
|
delete "build/packr/output/"
|
2019-03-09 19:43:33 -05:00
|
|
|
}
|
2017-12-28 15:26:11 -05:00
|
|
|
|
2019-08-24 18:29:21 -04:00
|
|
|
if(enableTemplates && (platform == PackrConfig.Platform.Windows64)){
|
2019-08-21 14:46:36 -04:00
|
|
|
copy{
|
2019-08-21 15:41:38 -04:00
|
|
|
into "build/packr/output"
|
2019-08-21 14:46:36 -04:00
|
|
|
from "${JDK_DIR}/templates/${platform.toString().toLowerCase()}"
|
|
|
|
}
|
|
|
|
|
|
|
|
copy{
|
2019-08-21 15:41:38 -04:00
|
|
|
into "build/packr/output/jre"
|
2019-08-21 15:50:58 -04:00
|
|
|
rename("${appName}.jar", "desktop.jar")
|
|
|
|
from "build/libs/${appName}.jar"
|
2019-08-21 14:46:36 -04:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
def config = new PackrConfig()
|
|
|
|
config.with{
|
|
|
|
config.executable = appName
|
|
|
|
config.platform = platform
|
|
|
|
verbose = true
|
|
|
|
bundleIdentifier = getPackage() + ".mac"
|
|
|
|
iconResource = ICON_DIR
|
2019-08-21 15:41:38 -04:00
|
|
|
outDir = file("build/packr/output")
|
2019-08-21 14:46:36 -04:00
|
|
|
mainClass = project.ext.mainClassName
|
2019-08-21 15:41:38 -04:00
|
|
|
classpath = ["desktop/build/packr/desktop.jar"]
|
|
|
|
removePlatformLibs = ["desktop/build/packr/desktop.jar"]
|
2019-08-21 14:46:36 -04: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-25 11:16:38 -04:00
|
|
|
if(platform != PackrConfig.Platform.MacOS){
|
2019-08-21 14:46:36 -04:00
|
|
|
copy{
|
2019-08-21 15:41:38 -04:00
|
|
|
into "build/packr/output/jre/"
|
|
|
|
from "build/packr/output/desktop.jar"
|
2019-08-21 14:46:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
delete{
|
2019-08-21 15:41:38 -04:00
|
|
|
delete "build/packr/output/desktop.jar"
|
2019-08-21 14:46:36 -04:00
|
|
|
}
|
2019-08-21 15:41:38 -04:00
|
|
|
|
|
|
|
file("build/packr/output/config.json").text = file("build/packr/output/config.json").text.replace("desktop.jar", "jre/desktop.jar")
|
2019-08-21 14:46:36 -04:00
|
|
|
}
|
2017-12-28 15:26:11 -05:00
|
|
|
|
2019-08-21 15:41:38 -04:00
|
|
|
if(platform == PackrConfig.Platform.MacOS){
|
|
|
|
copy{
|
2019-08-24 10:00:04 -04:00
|
|
|
into "build/packr/output/${appName}.app/Contents/"
|
|
|
|
from "build/packr/output/Contents/"
|
2019-08-21 15:41:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
delete{
|
2019-08-24 10:00:04 -04:00
|
|
|
delete "build/packr/output/Contents/"
|
2019-08-21 15:41:38 -04:00
|
|
|
}
|
|
|
|
}
|
2019-03-09 19:43:33 -05:00
|
|
|
}
|
2019-08-22 09:27:59 -04:00
|
|
|
|
2019-08-25 11:16:38 -04:00
|
|
|
if((platform == PackrConfig.Platform.Windows64 || platform == PackrConfig.Platform.Windows32)){
|
|
|
|
copy{
|
|
|
|
from "build/packr/output/jre/bin/msvcr100.dll"
|
|
|
|
into "build/packr/output/"
|
|
|
|
rename("msvcr100.dll", "MSVCR100.dll")
|
|
|
|
}
|
|
|
|
}
|
2019-08-30 16:39:40 -04:00
|
|
|
|
2019-08-22 09:27:59 -04:00
|
|
|
copy{
|
|
|
|
from "build/packr/output"
|
|
|
|
into "../deploy/${platform.toString()}"
|
|
|
|
}
|
2017-12-28 15:26:11 -05:00
|
|
|
}
|
2019-04-08 09:03:18 -04:00
|
|
|
|
2019-08-21 15:41:38 -04:00
|
|
|
task "zip${platform.toString()}"(type: Zip){
|
|
|
|
from "build/packr/output"
|
|
|
|
archiveName "${generateDeployName(platform.toString())}.zip"
|
|
|
|
destinationDir(file("../deploy"))
|
2017-12-28 15:26:11 -05:00
|
|
|
|
2019-08-21 15:41:38 -04:00
|
|
|
doLast{
|
|
|
|
delete{
|
|
|
|
delete "build/packr/"
|
|
|
|
}
|
2019-03-22 22:30:26 -04:00
|
|
|
}
|
2018-02-08 23:41:07 -05:00
|
|
|
}
|
2018-01-31 16:05:43 -05:00
|
|
|
|
2019-08-21 15:41:38 -04:00
|
|
|
finalizedBy "zip${platform.toString()}"
|
2019-08-22 16:13:39 -04:00
|
|
|
|
2018-01-31 16:05:43 -05:00
|
|
|
}
|
2019-08-21 14:46:36 -04:00
|
|
|
}
|