2017-04-30 08:25:59 +07:00
|
|
|
apply plugin: "java"
|
|
|
|
|
|
|
|
sourceCompatibility = 1.8
|
|
|
|
sourceSets.main.java.srcDirs = [ "src/" ]
|
|
|
|
|
2017-05-03 11:09:48 +07:00
|
|
|
project.ext.mainClassName = "io.anuke.mindustry.desktop.DesktopLauncher"
|
2017-08-09 07:18:31 +07:00
|
|
|
project.ext.assetsDir = new File("../core/assets");
|
|
|
|
|
2018-01-27 03:09:13 +07:00
|
|
|
def PACKR_DIR = "$System.env.PACKR_DIR"
|
2017-12-29 03:26:11 +07:00
|
|
|
def ICON_DIR = new File("core/assets/sprites/icon.icns")
|
2017-04-30 08:25:59 +07:00
|
|
|
|
|
|
|
task run(dependsOn: classes, type: JavaExec) {
|
|
|
|
main = project.mainClassName
|
|
|
|
classpath = sourceSets.main.runtimeClasspath
|
|
|
|
standardInput = System.in
|
|
|
|
workingDir = project.assetsDir
|
|
|
|
ignoreExitValue = true
|
2017-12-22 08:59:40 +07:00
|
|
|
if (project.hasProperty("appArgs")) {
|
|
|
|
args Eval.me(appArgs)
|
|
|
|
}
|
2017-04-30 08:25:59 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2018-02-02 10:16:00 +07:00
|
|
|
from files(sourceSets.main.output.classesDirs)
|
2017-04-30 08:25:59 +07:00
|
|
|
from files(sourceSets.main.output.resourcesDir)
|
|
|
|
from {configurations.compile.collect {zipTree(it)}}
|
|
|
|
from files(project.assetsDir);
|
|
|
|
|
|
|
|
manifest {
|
|
|
|
attributes 'Main-Class': project.mainClassName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dist.dependsOn classes
|
|
|
|
|
2017-08-09 07:18:31 +07:00
|
|
|
task clearOut(type: Delete){
|
|
|
|
delete "packr-out/"
|
|
|
|
}
|
|
|
|
|
|
|
|
ext.getPlatform = {
|
|
|
|
if(project.gradle.startParameter.taskNames.size() == 0 || !project.gradle.startParameter.taskNames.first().contains("packr")) return;
|
|
|
|
|
2018-01-23 00:46:00 +07:00
|
|
|
if(!project.hasProperty("version")){
|
|
|
|
throw new InvalidUserDataException("No version set. Set version with -Pversion=name");
|
|
|
|
}
|
|
|
|
|
2017-08-09 07:18:31 +07:00
|
|
|
if (project.hasProperty("platform")) {
|
|
|
|
def lc = platform.toLowerCase()
|
2017-12-25 08:50:00 +07:00
|
|
|
if(lc.equals("windows64")) {
|
|
|
|
return "windows64";
|
|
|
|
}else if(lc.equals("windows32")){
|
|
|
|
return "windows32";
|
2017-08-09 07:18:31 +07:00
|
|
|
}else if(lc.equals("linux")){
|
|
|
|
return "linux64";
|
|
|
|
}else if(lc.equals("mac")){
|
|
|
|
return "mac";
|
|
|
|
}else{
|
|
|
|
throw new InvalidUserDataException("Invalid platform. Set platform with -Pplatform=windows/linux/mac");
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
throw new InvalidUserDataException("No platform defined. Set platform with -Pplatform=windows/linux/mac");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-23 00:46:00 +07:00
|
|
|
ext.getDeployVersion = {
|
|
|
|
if(project.gradle.startParameter.taskNames.size() == 0 || !project.gradle.startParameter.taskNames.first().contains("packr")) return;
|
|
|
|
|
|
|
|
if(!project.hasProperty("deployversion")){
|
|
|
|
throw new InvalidUserDataException("No version set. Set version with -Pdeployversion=name");
|
|
|
|
}
|
|
|
|
|
|
|
|
return deployversion;
|
|
|
|
}
|
|
|
|
|
2017-12-29 03:26:11 +07:00
|
|
|
ext.getPackage = {
|
|
|
|
return project.ext.mainClassName.substring(0, project.ext.mainClassName.indexOf("desktop") - 1)
|
|
|
|
}
|
|
|
|
|
2017-08-09 07:18:31 +07:00
|
|
|
//note: call desktop:dist beforehand
|
|
|
|
task packrCmd(type: Exec) {
|
|
|
|
|
|
|
|
copy{
|
|
|
|
into PACKR_DIR
|
2017-12-25 02:40:08 +07:00
|
|
|
from "build/libs/desktop-release.jar"
|
2017-08-09 07:18:31 +07:00
|
|
|
}
|
|
|
|
|
2017-12-29 03:26:11 +07:00
|
|
|
commandLine "java", "-jar", PACKR_DIR+"packr.jar",
|
|
|
|
"--verbose",
|
|
|
|
"--bundle", getPackage(),
|
|
|
|
"--platform", getPlatform(),
|
|
|
|
"--executable", appName,
|
|
|
|
"--output", "packr-out/",
|
|
|
|
"--mainclass", project.ext.mainClassName,
|
|
|
|
"--jdk", PACKR_DIR+"jdk-"+getPlatform()+".zip",
|
|
|
|
"--icon", ICON_DIR.getAbsolutePath(),
|
|
|
|
"--classpath", "--", PACKR_DIR+"config.json"
|
2017-08-09 07:18:31 +07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-12-29 03:26:11 +07:00
|
|
|
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 PACKR_DIR + "zip.dll"
|
|
|
|
rename ("zip.dll", "ojdkbuild_zlib.dll")
|
|
|
|
|
|
|
|
doLast{
|
|
|
|
copy{
|
|
|
|
into "packr-out/jre/bin/"
|
|
|
|
from PACKR_DIR + "zip.dll"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-09 07:18:31 +07:00
|
|
|
task packrZip(type: Zip) {
|
|
|
|
dependsOn "packrCmd"
|
|
|
|
finalizedBy "clearOut"
|
2017-12-29 03:26:11 +07:00
|
|
|
|
|
|
|
if(getPlatform().equals("mac")){
|
|
|
|
dependsOn "fixMac"
|
|
|
|
}
|
|
|
|
|
|
|
|
if(getPlatform().equals("windows32")){
|
|
|
|
dependsOn "fixWindows32"
|
|
|
|
}
|
|
|
|
|
2017-08-09 07:18:31 +07:00
|
|
|
from "packr-out/"
|
2018-01-23 00:46:00 +07:00
|
|
|
archiveName appName + "-" + getPlatform() + "-" + getDeployVersion() + ".zip"
|
2017-08-09 07:18:31 +07:00
|
|
|
destinationDir(file("packr-export"))
|
2018-02-01 04:05:43 +07:00
|
|
|
|
|
|
|
doLast{
|
|
|
|
delete{
|
|
|
|
delete "null/"
|
|
|
|
}
|
|
|
|
}
|
2017-08-09 07:18:31 +07:00
|
|
|
}
|
|
|
|
|
2017-04-30 08:25:59 +07:00
|
|
|
eclipse {
|
|
|
|
project {
|
|
|
|
name = appName + "-desktop"
|
|
|
|
linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/core/assets'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
|
|
|
|
doLast {
|
|
|
|
def classpath = new XmlParser().parse(file(".classpath"))
|
|
|
|
new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
|
|
|
|
def writer = new FileWriter(file(".classpath"))
|
|
|
|
def printer = new XmlNodePrinter(new PrintWriter(writer))
|
|
|
|
printer.setPreserveWhitespace(true)
|
|
|
|
printer.print(classpath)
|
|
|
|
}
|
|
|
|
}
|