mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-11 07:39:39 +07:00
91 lines
2.7 KiB
Groovy
91 lines
2.7 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")){
|
|
def prefix = target.contains("32") ? "64" : ""
|
|
exclude('**.so', "**.dylib", "sdl-arc${prefix}.dll", "gdx${prefix}.dll", "gdx-freetype${prefix}.dll")
|
|
}
|
|
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-windows-${version}"
|
|
|
|
from "build/libs/$filename"
|
|
archiveBaseName = "$appName-${getTarget()}"
|
|
}
|
|
|
|
task ikdist{
|
|
dependsOn dist
|
|
finalizedBy ikZip
|
|
|
|
doLast{
|
|
def filename = "$appName-windows-${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", "-static", "-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
|
|
}
|
|
}
|
|
}
|
|
|