2019-08-22 02:41:38 +07:00
|
|
|
import com.badlogicgames.packr.Packr
|
|
|
|
import com.badlogicgames.packr.PackrConfig
|
|
|
|
|
2020-04-28 04:35:10 +07:00
|
|
|
import java.nio.ByteBuffer
|
|
|
|
import java.security.MessageDigest
|
|
|
|
|
2017-04-30 08:25:59 +07:00
|
|
|
sourceCompatibility = 1.8
|
2019-08-22 02:41:38 +07:00
|
|
|
sourceSets.main.java.srcDirs = [ "src/" ]
|
2017-04-30 08:25:59 +07:00
|
|
|
|
2019-12-25 13:39:38 +07:00
|
|
|
project.ext.mainClassName = "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-08-25 05:29:21 +07:00
|
|
|
def enableTemplates = true
|
2019-09-22 03:44:47 +07:00
|
|
|
def JDK_DIR = "$System.env.JDK_DIR"
|
2019-07-12 12:03:01 +07:00
|
|
|
def ICON_DIR = new File("core/assets/icons/icon.icns")
|
2020-04-28 04:35:10 +07:00
|
|
|
def spriteHashFile = new File(project.rootDir, "build/spritehash")
|
|
|
|
|
|
|
|
def hashDirectory = {
|
|
|
|
def root = new File(project.rootDir, "core/assets-raw/sprites/")
|
|
|
|
MessageDigest digest = MessageDigest.getInstance("MD5")
|
|
|
|
ByteBuffer buffer = ByteBuffer.allocate(16)
|
|
|
|
def files = []
|
|
|
|
root.eachFileRecurse{ file ->
|
2020-05-04 21:57:57 +07:00
|
|
|
if(!file.name.startsWith(".")) files += file
|
2020-04-28 04:35:10 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
files.sort()
|
|
|
|
|
|
|
|
for(File file : files){
|
|
|
|
buffer.position(0)
|
|
|
|
buffer.putLong(file.lastModified())
|
|
|
|
digest.update(buffer.array())
|
|
|
|
}
|
|
|
|
|
|
|
|
return digest.digest().encodeHex()
|
|
|
|
}
|
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
|
|
|
|
2020-05-04 21:57:57 +07:00
|
|
|
/*spriteHashFile.parentFile.mkdirs()
|
2020-04-28 04:35:10 +07:00
|
|
|
String spriteHash = hashDirectory()
|
|
|
|
if(spriteHashFile.exists() && spriteHashFile.text != spriteHash){
|
|
|
|
dependsOn ":tools:pack"
|
|
|
|
}
|
2020-05-04 21:57:57 +07:00
|
|
|
spriteHashFile.text = spriteHash*/
|
2020-04-28 04:35:10 +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"])
|
|
|
|
}
|
|
|
|
|
2019-12-05 08:05:01 +07:00
|
|
|
if(project.hasProperty("jvmArgs")){
|
|
|
|
jvmArgs((List<String>)Eval.me(project.getProperties()["jvmArgs"]))
|
|
|
|
}
|
|
|
|
|
2018-09-11 06:33:12 +07:00
|
|
|
if(args.contains("debug")){
|
2019-12-27 07:40:54 +07:00
|
|
|
main = "mindustry.debug.DebugLauncher"
|
2017-12-22 08:59:40 +07:00
|
|
|
}
|
2017-04-30 08:25:59 +07:00
|
|
|
}
|
|
|
|
|
2018-02-09 11:41:07 +07:00
|
|
|
|
2019-08-22 02:50:58 +07:00
|
|
|
task dist(type: Jar, dependsOn: classes){
|
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)
|
2020-05-15 09:00:04 +07:00
|
|
|
from {configurations.runtimeClasspath.collect{ it.isDirectory() ? it : zipTree(it) }}
|
2018-02-09 11:41:07 +07:00
|
|
|
from files(project.assetsDir)
|
|
|
|
|
2019-11-16 07:48:26 +07:00
|
|
|
archiveFileName = "${appName}.jar"
|
2019-08-22 02:50:58 +07:00
|
|
|
|
2018-12-14 06:01:51 +07:00
|
|
|
manifest{
|
2017-04-30 08:25:59 +07:00
|
|
|
attributes 'Main-Class': project.mainClassName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-22 20:27:59 +07:00
|
|
|
task steamtest(dependsOn: dist){
|
2018-12-14 06:01:51 +07:00
|
|
|
doLast{
|
2019-08-22 07:10:54 +07:00
|
|
|
copy{
|
2019-08-23 03:13:39 +07:00
|
|
|
from "build/libs/Mindustry.jar"
|
|
|
|
if(System.properties["os.name"].contains("Mac")){
|
2019-09-16 00:52:56 +07:00
|
|
|
into "/Users/anuke/Library/Application Support/Steam/steamapps/common/Mindustry/Mindustry.app/Contents/Resources"
|
2019-08-23 03:13:39 +07:00
|
|
|
}else{
|
2019-08-23 03:44:32 +07:00
|
|
|
into "/home/anuke/.steam/steam/steamapps/common/Mindustry/jre"
|
2019-08-23 03:13:39 +07:00
|
|
|
}
|
2019-08-23 03:19:29 +07:00
|
|
|
rename("Mindustry.jar", "desktop.jar")
|
2018-02-09 11:41:07 +07:00
|
|
|
}
|
|
|
|
}
|
2017-08-09 07:18:31 +07:00
|
|
|
}
|
|
|
|
|
2019-08-22 01:46:36 +07:00
|
|
|
PackrConfig.Platform.values().each{ platform ->
|
|
|
|
task "packr${platform.toString()}"{
|
2019-08-22 02:50:58 +07:00
|
|
|
dependsOn dist
|
2019-03-23 09:30:26 +07:00
|
|
|
|
2019-03-10 07:43:33 +07:00
|
|
|
doLast{
|
2019-08-22 02:41:38 +07:00
|
|
|
copy{
|
|
|
|
into "build/packr/"
|
2019-08-22 02:50:58 +07:00
|
|
|
rename("${appName}.jar", "desktop.jar")
|
|
|
|
from "build/libs/${appName}.jar"
|
2019-08-22 02:41:38 +07:00
|
|
|
}
|
2019-03-10 07:43:33 +07:00
|
|
|
|
|
|
|
delete{
|
2019-08-22 02:41:38 +07:00
|
|
|
delete "build/packr/output/"
|
2019-03-10 07:43:33 +07:00
|
|
|
}
|
2017-12-29 03:26:11 +07:00
|
|
|
|
2019-08-25 05:29:21 +07:00
|
|
|
if(enableTemplates && (platform == PackrConfig.Platform.Windows64)){
|
2019-08-22 01:46:36 +07:00
|
|
|
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"
|
2019-08-22 02:50:58 +07:00
|
|
|
rename("${appName}.jar", "desktop.jar")
|
|
|
|
from "build/libs/${appName}.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
|
|
|
|
2020-03-18 07:01:44 +07:00
|
|
|
vmArgs = []
|
2019-08-22 01:46:36 +07:00
|
|
|
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 22:16:38 +07:00
|
|
|
if(platform != PackrConfig.Platform.MacOS){
|
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{
|
2019-08-24 21:00:04 +07:00
|
|
|
into "build/packr/output/${appName}.app/Contents/"
|
|
|
|
from "build/packr/output/Contents/"
|
2019-08-22 02:41:38 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
delete{
|
2019-08-24 21:00:04 +07:00
|
|
|
delete "build/packr/output/Contents/"
|
2019-08-22 02:41:38 +07:00
|
|
|
}
|
|
|
|
}
|
2019-03-10 07:43:33 +07:00
|
|
|
}
|
2019-08-22 20:27:59 +07:00
|
|
|
|
2019-08-25 22:16:38 +07: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-11-08 02:58:51 +07:00
|
|
|
}
|
2019-11-07 01:59:35 +07:00
|
|
|
|
2019-11-08 02:58:51 +07:00
|
|
|
if(versionModifier.contains("steam")){
|
|
|
|
copy{
|
|
|
|
def lib = platform == PackrConfig.Platform.MacOS || platform == PackrConfig.Platform.Linux64 ? "lib" : ""
|
|
|
|
from zipTree(platform == PackrConfig.Platform.MacOS ? "build/packr/output/${appName}.app/Contents/Resources/desktop.jar" : "build/packr/output/jre/desktop.jar").matching{
|
|
|
|
include "${lib}steamworks4j${platform == PackrConfig.Platform.Windows64 ? '64.dll' : platform == PackrConfig.Platform.Windows32 ? '.dll' : platform == PackrConfig.Platform.Linux64 ? '.so' : '.dylib'}"
|
|
|
|
include "${lib}steam_api${platform == PackrConfig.Platform.Windows64 ? '64.dll' : platform == PackrConfig.Platform.Windows32 ? '.dll' : platform == PackrConfig.Platform.Linux64 ? '.so' : '.dylib'}"
|
2019-11-07 01:59:35 +07:00
|
|
|
}
|
2019-11-24 09:27:52 +07:00
|
|
|
into platform != PackrConfig.Platform.MacOS ? "build/packr/output/" : "build/packr/output/${appName}.app/Contents/Resources"
|
2019-11-07 01:59:35 +07:00
|
|
|
}
|
2019-08-25 22:16:38 +07:00
|
|
|
}
|
2019-08-31 03:39:40 +07:00
|
|
|
|
2019-08-22 20:27:59 +07:00
|
|
|
copy{
|
|
|
|
from "build/packr/output"
|
|
|
|
into "../deploy/${platform.toString()}"
|
|
|
|
}
|
2017-12-29 03:26:11 +07:00
|
|
|
}
|
2019-04-08 20:03:18 +07:00
|
|
|
|
2019-08-22 02:41:38 +07:00
|
|
|
task "zip${platform.toString()}"(type: Zip){
|
|
|
|
from "build/packr/output"
|
2019-11-16 07:48:26 +07:00
|
|
|
archiveFileName = "${generateDeployName(platform.toString())}.zip"
|
|
|
|
destinationDirectory = (file("../deploy"))
|
2017-12-29 03:26:11 +07:00
|
|
|
|
2019-08-22 02:41:38 +07:00
|
|
|
doLast{
|
|
|
|
delete{
|
|
|
|
delete "build/packr/"
|
|
|
|
}
|
2019-03-23 09:30:26 +07:00
|
|
|
}
|
2018-02-09 11:41:07 +07:00
|
|
|
}
|
2018-02-01 04:05:43 +07:00
|
|
|
|
2019-08-22 02:41:38 +07:00
|
|
|
finalizedBy "zip${platform.toString()}"
|
2019-08-23 03:13:39 +07:00
|
|
|
|
2018-02-01 04:05:43 +07:00
|
|
|
}
|
2019-08-22 01:46:36 +07:00
|
|
|
}
|