-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle
174 lines (140 loc) · 5.27 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import java.util.jar.JarEntry
import java.util.jar.JarOutputStream
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '2.0.4'
}
version 'alpha-0.9.1'
sourceSets.main.java.srcDirs = ["src"]
sourceSets.test.java.srcDirs = ["test"]
"java SyncBundles.java ${version}".execute().waitForProcessOutput(System.out, System.err)
ext {
//the build number that this mod is made for
mindustryVersion = "v146"
uncVersion = "1.8.10"
//version of SDK you will be using
minSdkAPI = 30
sdkRoot = System.getenv("ANDROID_HOME")
}
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.compilerArgs.addAll(['--release', '8'])
}
dependencies {
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://raw.githubusercontent.com/Zelaux/MindustryRepo/master/repository' }
maven { url 'https://www.jitpack.io' }
}
compileOnly "com.github.Anuken.Arc:arc-core:$mindustryVersion"
compileOnly "com.github.Anuken.Mindustry:core:$mindustryVersion"
compileOnly "com.github.EB-wilson.UniverseCore:mindustry:$uncVersion"
compileOnly "com.github.EB-wilson.UniverseCore:utilties:$uncVersion"
compileOnly "com.github.EB-wilson.UniverseCore:abstract:$uncVersion"
compileOnly "com.github.EB-wilson.UniverseCore:implabstract:$uncVersion"
compileOnly "com.github.EB-wilson.UniverseCore:dynamilizer:$uncVersion"
compileOnly "com.github.EB-wilson.UniverseCore:annotations:$uncVersion"
compileOnly "com.github.EB-wilson:TooManyItems:1.2"
implementation "com.github.EB-wilson.JavaDynamilizer:annotations:V1.8-A3"
annotationProcessor "com.github.EB-wilson.UniverseCore:annotations:$uncVersion"
annotationProcessor "com.github.EB-wilson.JavaDynamilizer:apt:V1.8-A3"
}
tasks.register('jarAndroid') {
dependsOn shadowJar
doLast {
try {
File fi = new File("$sdkRoot/platforms/")
if (!fi.exists()) throw new RuntimeException("android SDK platfroms was not found")
def platformRoot = fi.listFiles().sort().reverse().find { f -> new File(f, "android.jar").exists() }
//collect dependencies needed for desugaring
def dependencies = (configurations.compileClasspath.asList() + configurations.runtimeClasspath.asList() + [new File(platformRoot, "android.jar")]).collect { "--classpath $it.path" }.join(" ")
try {
System.out.println("build android dex...")
//dex and desugar files - this requires d8 in your PATH
"d8 $dependencies --min-api 14 --output ${rootProject.name}-android.jar ${project.archivesBaseName}-desktop.jar"
.execute(null, new File("$buildDir/libs")).waitForProcessOutput(System.out, System.err)
}
catch (Throwable ignored) {
def d8 = new File("$sdkRoot/build-tools/").listFiles().find {
it.listFiles().any {
it.name.contains("d8")
} && Integer.valueOf(it.name.substring(0, 2)) >= minSdkAPI
}.listFiles().find { it.name.contains("d8") }
"$d8 $dependencies --min-api 14 --output ${rootProject.name}-android.jar ${project.archivesBaseName}-desktop.jar"
.execute(null, new File("$buildDir/libs")).waitForProcessOutput(System.out, System.err)
}
}
catch (Throwable ignored) {
System.out.println("[WARNING] d8 tool or platform tools was not found, if you was installed android SDK, please check your environment variable")
delete(
files("${rootProject.buildDir}/libs/${rootProject.name}-android.jar")
)
def out = new JarOutputStream(new FileOutputStream("${rootProject.buildDir}/libs/${rootProject.name}-android.jar"))
out.putNextEntry(new JarEntry("non-androidMod.txt"))
StringReader reader = new StringReader(
"this mod is don't have classes.dex for android, please consider recompile with a SDK or run this mod on desktop only"
)
int r
while ((r = reader.read()) != -1) {
out.write(r)
out.flush()
}
out.close()
}
}
}
shadowJar {
archiveFileName = "${project.archivesBaseName}-desktop.jar"
from(rootDir) {
include "mod.hjson"
include "icon.png"
include "contributors.hjson"
}
from("assets/") {
include "**"
}
}
tasks.register('deploy', Jar) {
dependsOn jarAndroid
dependsOn shadowJar
archiveFileName = "${project.archivesBaseName}.jar"
from {
[
zipTree("$buildDir/libs/${project.archivesBaseName}-desktop.jar"),
zipTree("$buildDir/libs/${project.archivesBaseName}-android.jar")
]
}
doLast {
if (project.properties.get("modOutputDir") != null && !project.properties.get("modOutputDir").isEmpty()) {
copy {
into("$modOutputDir/")
from("$buildDir/libs/${project.archivesBaseName}.jar")
}
}
}
}
tasks.register('deployDesktop', Jar) {
dependsOn shadowJar
archiveFileName = "${project.archivesBaseName}.jar"
from {
[zipTree("$buildDir/libs/${project.archivesBaseName}-desktop.jar")]
}
doLast {
if (project.properties.get("modOutputDir") != null && !project.properties.get("modOutputDir").isEmpty()) {
copy {
into("$modOutputDir/")
from("$buildDir/libs/${project.archivesBaseName}.jar")
}
}
}
}
tasks.register('debugMod', JavaExec) {
dependsOn classes
dependsOn deployDesktop
main = "-jar"
args = [
project.properties.get("debugGamePath"),
"-debug"
]
}