generated from Sonnicon/mindustry-modtemplate
-
Notifications
You must be signed in to change notification settings - Fork 24
/
build.gradle
81 lines (62 loc) · 2.58 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
apply plugin: "java"
sourceSets {
main.java.srcDir("src/")
main.resources.srcDir("assets/")
}
ext {
mindustryVersion = 'v145.1'
artifactFilename = "Informatis"
sdkRoot = System.getenv("ANDROID_HOME") ?: System.getenv("ANDROID_SDK_ROOT")
}
java {
targetCompatibility = 8
sourceCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
maven { url "https://raw.githubusercontent.com/Zelaux/MindustryRepo/master/repository" }
maven { url "https://jitpack.io" }
}
dependencies {
compileOnly "com.github.Anuken.Mindustry:core:$mindustryVersion"
compileOnly "com.github.Anuken.Arc:arc-core:$mindustryVersion"
annotationProcessor 'com.github.Anuken:jabel:0.8.0'
}
jar {
archiveFileName = "${artifactFilename}Desktop.jar"
from{
configurations.runtimeClasspath.collect{ it.isDirectory() ? it : zipTree(it) }
}
}
tasks.register('jarAndroid', Jar) {
dependsOn "jar"
doLast{
if(!sdkRoot || !new File(sdkRoot.toString()).exists()) throw new GradleException("No valid Android SDK found. Ensure that ANDROID_HOME is set to your Android SDK directory.")
def platformRoot = new File("$sdkRoot/platforms/").listFiles().sort().reverse().find{ f -> new File(f, "android.jar").exists()}
if(!platformRoot) throw new GradleException("No android.jar found. Ensure that you have an Android platform installed.")
//collect dependencies needed for de-sugaring
def dependencies = (configurations.compileClasspath.asList() + configurations.runtimeClasspath.asList() + [new File(platformRoot, "android.jar")]).collect{ "--classpath $it.path" }.join(" ")
//dex and desugar files - this requires d8 in your PATH
"d8 $dependencies --min-api 14 --output ${artifactFilename}Android.jar ${artifactFilename}Desktop.jar"
.execute(null, new File("$buildDir/libs")).waitForProcessOutput(System.out, System.err)
}
}
tasks.register('deploy', Jar) {
dependsOn "jarAndroid"
dependsOn "jar"
archiveFileName.set("${artifactFilename}.jar")
from{ [zipTree("$buildDir/libs/${artifactFilename}Desktop.jar"), zipTree("$buildDir/libs/${artifactFilename}Android.jar")] }
doLast{
delete{
delete "$buildDir/libs/${artifactFilename}Desktop.jar"
delete "$buildDir/libs/${artifactFilename}Android.jar"
}
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.compilerArgs += ["-Xlint:all"]
if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
options.compilerArgs.addAll(['--release', '8'])
}
}