forked from Yuria-Shikibe/NewHorizonMod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
124 lines (103 loc) · 3.74 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
apply plugin: "java"
version '1.0'
sourceSets.main.java.srcDirs = ["src"]
repositories{
mavenCentral()
maven{ url 'https://www.jitpack.io' }
}
ext{
//the build number that this mod is made for
mindustryVersion = 'v135'
//version of SDK you will be using
sdkVersion = '30'
sdkRoot = System.getenv("ANDROID_HOME")
gameData = 'C:/Users/Administrator/AppData/Roaming/Mindustry'
doExec = { cmd ->
def proc = cmd.execute(null, new File("$buildDir/libs"))
proc.waitForProcessOutput(System.out, System.err)
}
}
//java 8 backwards compatibility flag
allprojects{
tasks.withType(JavaCompile){
if(JavaVersion.current() != JavaVersion.VERSION_1_8){
options.compilerArgs.addAll(['--release', '8'])
}
//
// doFirst {
// options.compilerArgs.addAll(['--release', '14', "--enable-preview"])
// }
}
}
dependencies{
compileOnly 'org.jetbrains:annotations:22.0.0'
// compileOnly "com.github.Anuken.Mindustry:annotations:$mindustryVersion"
compileOnly "com.github.Anuken.Arc:arc-core:$mindustryVersion"
compileOnly "com.github.Anuken.Mindustry:core:$mindustryVersion"
}
task jarAndroid{
dependsOn "jar"
doLast{
//collect dependencies needed for desugaring
def files = (configurations.compileClasspath.asList() + configurations.runtimeClasspath.asList() + [new File("$sdkRoot/platforms/android-$sdkVersion/android.jar")])
def dependencies = files.collect{ "--classpath $it.path" }.join(" ")
//dex and desugar files - this requires d8 in your PATH
doExec("d8 $dependencies --min-api 14 --output ${project.archivesBaseName}Android.jar ${project.archivesBaseName}Desktop.jar")
}
}
jar{
archiveFileName = "${project.archivesBaseName}Desktop.jar"
from{
configurations.runtimeClasspath.collect{ it.isDirectory() ? it : zipTree(it) }
}
from(rootDir){
include "mod.hjson"
}
from("assets/"){
include "**"
}
}
task deleteLast{
def fi = new File("$gameData/mods/NewHorizonModDesktop.jar");
if(fi.exists()){
// Class<?> fileSys = ClassLoader.getSystemClassLoader().loadClass("java.io.DefaultFileSystem");
// FileSystem system = (FileSystem)fileSys.getMethod("getFileSystem()").invoke(null, new Object[]{});
System.out.println("Delete Old:" + fi.delete())
}
}
task debugMod{
dependsOn deleteLast
dependsOn jar
def fi = new File("$rootDir/build/libs/NewHorizonModDesktop.jar")
// if(!fi.exists())throw new RuntimeException("Missing Mod File")
// if(!fi.renameTo("$gameData/mods/NewHorizonModDesktop.jar"))throw new RuntimeException("Failed to replace the old version mod")
//
// doLast {
// try{
// Runtime.getRuntime().exec("java -jar $rootDir/build/libs/Mindustry.jar")
// }catch(IOException io){
// System.out.print(io)
// }
// }
}
task deploy(type : Jar){
def fi = new File("$rootDir/mod.hjson")
fi.withReader { reader ->
def lines = reader.readLines()
fi.withWriter { writer ->
lines.each { line ->
def check = line.split(":")[0].equals("minGameVersion")
if(!check) writer.append("$line\r\n")
}
writer.append("minGameVersion: ${mindustryVersion.split("v")[1]}\r\n")
}
}
dependsOn jarAndroid
dependsOn jar
archiveFileName = "${project.archivesBaseName}.jar"
from{ [zipTree("$buildDir/libs/${project.archivesBaseName}Desktop.jar"), zipTree("$buildDir/libs/${project.archivesBaseName}Android.jar")] }
doLast{
delete{ delete "$buildDir/libs/${project.archivesBaseName}Desktop.jar" }
delete{ delete "$buildDir/libs/${project.archivesBaseName}Android.jar" }
}
}