Mindustry/desktop-sdl/build.gradle

88 lines
2.6 KiB
Groovy
Raw Normal View History

2019-07-25 21:14:01 +07:00
apply plugin: "java"
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/" ]
project.ext.mainClassName = "io.anuke.mindustry.desktopsdl.DesktopLauncher"
2019-07-25 21:14:01 +07:00
project.ext.assetsDir = new File("../core/assets")
2019-08-01 09:49:41 +07:00
def IKVM_DIR = System.env.IKVM_HOME
2019-07-27 20:27:03 +07:00
def getTarget = { return project.hasProperty("target") ? project.properties["target"] : "windows" }
2019-07-25 21:14:01 +07:00
2019-08-01 21:37:04 +07:00
task run(dependsOn: classes, type: JavaExec){
2019-07-25 21:14:01 +07:00
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"
}
2019-07-25 21:14:01 +07:00
}
2019-08-01 21:37:04 +07:00
task dist(type: Jar, dependsOn: classes){
2019-07-25 21:14:01 +07:00
from files(sourceSets.main.output.classesDirs)
from files(sourceSets.main.output.resourcesDir)
from {configurations.compile.collect {zipTree(it)}}
2019-08-01 09:49:41 +07:00
from files(project.assetsDir)
2019-07-25 21:14:01 +07:00
//use target = all for all platforms
2019-07-27 20:27:03 +07:00
def target = getTarget()
2019-08-15 08:48:36 +07:00
if(target.contains("windows")) exclude('**.so', "**.dylib")
2019-07-25 21:14:01 +07:00
if(target == "mac") exclude('**.so', "**.dll")
if(target == "linux") exclude('**.dll', "**.dylib")
archivesBaseName = appName + "-" + target
2019-08-01 21:37:04 +07:00
manifest{
2019-07-25 21:14:01 +07:00
attributes 'Main-Class': project.mainClassName
}
}
task ikZip(type: Zip){
2019-08-06 20:17:26 +07:00
def filename = "$appName-${getTarget()}-${version}"
2019-07-25 21:14:01 +07:00
from "build/libs/$filename"
2019-08-06 20:17:26 +07:00
archiveName = "$appName-${getTarget()}-${getVersionString()}.zip"
2019-07-25 21:14:01 +07:00
}
task ikdist{
dependsOn dist
finalizedBy ikZip
doLast{
2019-08-06 20:17:26 +07:00
def filename = "$appName-${getTarget()}-${version}"
2019-07-25 21:14:01 +07:00
def folder = "build/libs/$filename"
2019-08-01 15:28:01 +07:00
def baseArgs = System.properties['os.name'].toLowerCase().contains('windows') ? [] : ["mono"]
2019-08-12 03:55:32 +07:00
def args = baseArgs + ["$IKVM_DIR/ikvmc.exe", "-target:winexe", "-out:build/libs/${filename}.exe", "build/libs/${filename}.jar"]
2019-07-25 21:14:01 +07:00
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"]
2019-07-25 21:14:01 +07:00
}
exec{
commandLine args
}
copy{
from file("build/libs/${filename}.exe")
into file(folder)
}
copy{
2019-08-01 09:49:41 +07:00
from(getTarget().contains("32") ? "$IKVM_DIR/libraries_32" : "$IKVM_DIR/libraries")
2019-07-25 21:14:01 +07:00
into folder
}
}
}