mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-11-11 14:56:10 +03:00
436c76fd2f
# Conflicts: # core/src/mindustry/world/blocks/BuildBlock.java
184 lines
6.4 KiB
Groovy
184 lines
6.4 KiB
Groovy
import com.badlogicgames.packr.Packr
|
|
import com.badlogicgames.packr.PackrConfig
|
|
|
|
apply plugin: "java"
|
|
|
|
sourceCompatibility = 1.8
|
|
sourceSets.main.java.srcDirs = [ "src/" ]
|
|
|
|
project.ext.mainClassName = "mindustry.desktop.DesktopLauncher"
|
|
project.ext.assetsDir = new File("../core/assets")
|
|
|
|
def enableTemplates = true
|
|
def JDK_DIR = "$System.env.JDK_DIR"
|
|
def ICON_DIR = new File("core/assets/icons/icon.icns")
|
|
|
|
task run(dependsOn: classes, type: JavaExec){
|
|
main = project.mainClassName
|
|
classpath = sourceSets.main.runtimeClasspath
|
|
standardInput = System.in
|
|
workingDir = project.assetsDir
|
|
ignoreExitValue = true
|
|
|
|
if(System.getProperty("os.name").toLowerCase().contains("mac")){
|
|
jvmArgs("-XstartOnFirstThread", "-Djava.awt.headless=true")
|
|
}
|
|
|
|
if(project.hasProperty("args")){
|
|
args Eval.me(project.getProperties()["args"])
|
|
}
|
|
|
|
if(project.hasProperty("jvmArgs")){
|
|
jvmArgs((List<String>)Eval.me(project.getProperties()["jvmArgs"]))
|
|
}
|
|
|
|
if(args.contains("debug")){
|
|
main = "mindustry.debug.DebugLauncher"
|
|
}
|
|
}
|
|
|
|
|
|
task dist(type: Jar, dependsOn: classes){
|
|
from files(sourceSets.main.output.classesDirs)
|
|
from files(sourceSets.main.output.resourcesDir)
|
|
from {configurations.compile.collect{ it.isDirectory() ? it : zipTree(it) }}
|
|
from files(project.assetsDir)
|
|
|
|
archiveFileName = "${appName}.jar"
|
|
|
|
manifest{
|
|
attributes 'Main-Class': project.mainClassName
|
|
}
|
|
}
|
|
|
|
task steamtest(dependsOn: dist){
|
|
doLast{
|
|
copy{
|
|
from "build/libs/Mindustry.jar"
|
|
if(System.properties["os.name"].contains("Mac")){
|
|
into "/Users/anuke/Library/Application Support/Steam/steamapps/common/Mindustry/Mindustry.app/Contents/Resources"
|
|
}else{
|
|
into "/home/anuke/.steam/steam/steamapps/common/Mindustry/jre"
|
|
}
|
|
rename("Mindustry.jar", "desktop.jar")
|
|
}
|
|
}
|
|
}
|
|
|
|
PackrConfig.Platform.values().each{ platform ->
|
|
task "packr${platform.toString()}"{
|
|
dependsOn dist
|
|
|
|
doLast{
|
|
copy{
|
|
into "build/packr/"
|
|
rename("${appName}.jar", "desktop.jar")
|
|
from "build/libs/${appName}.jar"
|
|
}
|
|
|
|
delete{
|
|
delete "build/packr/output/"
|
|
}
|
|
|
|
if(enableTemplates && (platform == PackrConfig.Platform.Windows64)){
|
|
copy{
|
|
into "build/packr/output"
|
|
from "${JDK_DIR}/templates/${platform.toString().toLowerCase()}"
|
|
}
|
|
|
|
copy{
|
|
into "build/packr/output/jre"
|
|
rename("${appName}.jar", "desktop.jar")
|
|
from "build/libs/${appName}.jar"
|
|
}
|
|
}else{
|
|
def config = new PackrConfig()
|
|
config.with{
|
|
config.executable = appName
|
|
config.platform = platform
|
|
verbose = true
|
|
bundleIdentifier = getPackage() + ".mac"
|
|
iconResource = ICON_DIR
|
|
outDir = file("build/packr/output")
|
|
mainClass = project.ext.mainClassName
|
|
classpath = ["desktop/build/packr/desktop.jar"]
|
|
removePlatformLibs = ["desktop/build/packr/desktop.jar"]
|
|
|
|
vmArgs = []
|
|
minimizeJre = "desktop/packr_minimize.json"
|
|
jdk = JDK_DIR + "jdk-${platform.toString().toLowerCase()}.zip"
|
|
|
|
if(platform == PackrConfig.Platform.MacOS){
|
|
vmArgs += "XstartOnFirstThread"
|
|
}
|
|
}
|
|
|
|
new Packr().pack(config)
|
|
|
|
if(platform != PackrConfig.Platform.MacOS){
|
|
copy{
|
|
into "build/packr/output/jre/"
|
|
from "build/packr/output/desktop.jar"
|
|
}
|
|
|
|
delete{
|
|
delete "build/packr/output/desktop.jar"
|
|
}
|
|
|
|
file("build/packr/output/config.json").text = file("build/packr/output/config.json").text.replace("desktop.jar", "jre/desktop.jar")
|
|
}
|
|
|
|
if(platform == PackrConfig.Platform.MacOS){
|
|
copy{
|
|
into "build/packr/output/${appName}.app/Contents/"
|
|
from "build/packr/output/Contents/"
|
|
}
|
|
|
|
delete{
|
|
delete "build/packr/output/Contents/"
|
|
}
|
|
}
|
|
}
|
|
|
|
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")
|
|
}
|
|
}
|
|
|
|
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'}"
|
|
}
|
|
into platform != PackrConfig.Platform.MacOS ? "build/packr/output/" : "build/packr/output/${appName}.app/Contents/Resources"
|
|
}
|
|
}
|
|
|
|
copy{
|
|
from "build/packr/output"
|
|
into "../deploy/${platform.toString()}"
|
|
}
|
|
}
|
|
|
|
task "zip${platform.toString()}"(type: Zip){
|
|
from "build/packr/output"
|
|
archiveFileName = "${generateDeployName(platform.toString())}.zip"
|
|
destinationDirectory = (file("../deploy"))
|
|
|
|
doLast{
|
|
delete{
|
|
delete "build/packr/"
|
|
}
|
|
}
|
|
}
|
|
|
|
finalizedBy "zip${platform.toString()}"
|
|
|
|
}
|
|
}
|