Mindustry/desktop-sdl/build.gradle
2019-08-14 21:48:36 -04:00

88 lines
2.6 KiB
Groovy

apply plugin: "java"
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/" ]
project.ext.mainClassName = "io.anuke.mindustry.desktopsdl.DesktopLauncher"
project.ext.assetsDir = new File("../core/assets")
def IKVM_DIR = System.env.IKVM_HOME
def getTarget = { return project.hasProperty("target") ? project.properties["target"] : "windows" }
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(args.contains("debug")){
main = "io.anuke.mindustry.DebugLauncher"
}
}
task dist(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)
//use target = all for all platforms
def target = getTarget()
if(target.contains("windows")) exclude('**.so', "**.dylib")
if(target == "mac") exclude('**.so', "**.dll")
if(target == "linux") exclude('**.dll', "**.dylib")
archivesBaseName = appName + "-" + target
manifest{
attributes 'Main-Class': project.mainClassName
}
}
task ikZip(type: Zip){
def filename = "$appName-${getTarget()}-${version}"
from "build/libs/$filename"
archiveName = "$appName-${getTarget()}-${getVersionString()}.zip"
}
task ikdist{
dependsOn dist
finalizedBy ikZip
doLast{
def filename = "$appName-${getTarget()}-${version}"
def folder = "build/libs/$filename"
def baseArgs = System.properties['os.name'].toLowerCase().contains('windows') ? [] : ["mono"]
def args = baseArgs + ["$IKVM_DIR/ikvmc.exe", "-target:winexe", "-out:build/libs/${filename}.exe", "build/libs/${filename}.jar"]
if(file("../core/assets/sprites/icon.ico").exists()){
args += ["-win32icon:../core/assets/sprites/icon.ico"]
}else if(file("../core/assets/icons/icon.ico").exists()){
args += ["-win32icon:../core/assets/icons/icon.ico"]
}
exec{
commandLine args
}
copy{
from file("build/libs/${filename}.exe")
into file(folder)
}
copy{
from(getTarget().contains("32") ? "$IKVM_DIR/libraries_32" : "$IKVM_DIR/libraries")
into folder
}
}
}