mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-10 23:28:52 +07:00
156 lines
3.9 KiB
Groovy
156 lines
3.9 KiB
Groovy
apply plugin: "java"
|
|
|
|
sourceCompatibility = 1.8
|
|
sourceSets.main.java.srcDirs = ["src/"]
|
|
|
|
project.ext.mainClassName = "io.anuke.mindustry.desktop.DesktopLauncher"
|
|
project.ext.assetsDir = new File("../core/assets")
|
|
|
|
import com.badlogicgames.packr.PackrConfig
|
|
import com.badlogicgames.packr.Packr
|
|
|
|
def JDK_DIR = "$System.env.PACKR_DIR"
|
|
def ICON_DIR = new File("core/assets/sprites/icon.icns")
|
|
|
|
ext.getPlatform = {
|
|
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
|
|
}else{
|
|
throw new InvalidUserDataException("Invalid platform. Set platform with -Pplatform=windows64/windows32/linux/mac")
|
|
}
|
|
}
|
|
|
|
task run(dependsOn: classes, type: JavaExec){
|
|
main = project.mainClassName
|
|
classpath = sourceSets.main.runtimeClasspath
|
|
standardInput = System.in
|
|
workingDir = project.assetsDir
|
|
if(System.getProperty("os.name").toLowerCase().contains("mac")){
|
|
jvmArgs "-XstartOnFirstThread"
|
|
}
|
|
ignoreExitValue = true
|
|
if(project.hasProperty("args")){
|
|
args Eval.me(project.getProperties()["args"])
|
|
}
|
|
|
|
if(args.contains("debug")){
|
|
main = "io.anuke.mindustry.DebugLauncher"
|
|
}
|
|
}
|
|
|
|
task debug(dependsOn: classes, type: JavaExec){
|
|
main = project.mainClassName
|
|
classpath = sourceSets.main.runtimeClasspath
|
|
standardInput = System.in
|
|
workingDir = project.assetsDir
|
|
ignoreExitValue = true
|
|
debug = true
|
|
}
|
|
|
|
task dist(type: Jar){
|
|
dependsOn classes
|
|
|
|
writeVersion()
|
|
|
|
from files(sourceSets.main.output.classesDirs)
|
|
from files(sourceSets.main.output.resourcesDir)
|
|
from{ configurations.compile.collect{ zipTree(it) } }
|
|
from files(project.assetsDir)
|
|
|
|
manifest{
|
|
attributes 'Main-Class': project.mainClassName
|
|
}
|
|
}
|
|
|
|
task clearOut(type: Delete){
|
|
doLast{
|
|
delete "packr-out/"
|
|
}
|
|
}
|
|
|
|
//note: call desktop:dist beforehand
|
|
task packrCmd(){
|
|
|
|
doLast{
|
|
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"]
|
|
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"
|
|
}
|
|
}
|
|
|
|
new Packr().pack(config)
|
|
}
|
|
}
|
|
|
|
task fixMac(type: Copy){
|
|
dependsOn "packrCmd"
|
|
|
|
into "packr-out/" + appName + ".app/Contents/"
|
|
from "packr-out/Contents/"
|
|
|
|
doLast{
|
|
delete{
|
|
delete "packr-out/Contents/"
|
|
}
|
|
}
|
|
}
|
|
|
|
task fixWindows32(type: Copy){
|
|
dependsOn "packrCmd"
|
|
|
|
into "packr-out/jre/bin/"
|
|
from JDK_DIR + "zip.dll"
|
|
rename("zip.dll", "ojdkbuild_zlib.dll")
|
|
|
|
doLast{
|
|
copy{
|
|
into "packr-out/jre/bin/"
|
|
from JDK_DIR + "zip.dll"
|
|
}
|
|
}
|
|
}
|
|
|
|
task packrZip(){
|
|
dependsOn "packrCmd"
|
|
finalizedBy "clearOut"
|
|
|
|
if(project.hasProperty("platform")){
|
|
|
|
if(getPlatform() == "mac"){
|
|
dependsOn "fixMac"
|
|
}
|
|
|
|
if(getPlatform() == "windows32"){
|
|
dependsOn "fixWindows32"
|
|
}
|
|
|
|
task zip(type: Zip){
|
|
from "packr-out/"
|
|
archiveName "$appName-${getPlatform()}-${getVersionString()}.zip"
|
|
destinationDir(file("packr-export"))
|
|
}
|
|
|
|
finalizedBy 'zip'
|
|
}
|
|
}
|