-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
104 lines (80 loc) · 3.67 KB
/
Copy pathbuild.gradle
File metadata and controls
104 lines (80 loc) · 3.67 KB
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
import groovy.json.JsonSlurper
plugins {
id 'java'
}
def json = new JsonSlurper()
def mod = json.parse("$rootDir/mod.json" as File)
group = "net.buj"
version = "${mod['version']}"
compileJava.options.encoding = "UTF-8"
repositories {
mavenCentral()
ivy {
url 'https://github.com/'
patternLayout { artifact '/[organisation]/[module]/releases/download/[revision]/dependencies.jar' }
metadataSources { artifact() }
}
}
allprojects {
tasks.withType(JavaCompile).configureEach {
targetCompatibility = 8
sourceCompatibility = 8
options.forkOptions.jvmArgs += [
'--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
'--add-opens=java.base/sun.reflect.annotation=ALL-UNNAMED'
]
}
}
dependencies {
compileOnly "Anuken:Mindustry:$mindustryVersion"
compileOnly "org.projectlombok:lombok:1.18.42"
annotationProcessor "org.projectlombok:lombok:1.18.42"
}
jar {
archiveFileName = "${jar.archiveBaseName.get()}Desktop.jar"
from new File("$rootDir/mod.json")
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
def sdkRoot = System.getenv("ANDROID_HOME") ?: System.getenv("ANDROID_SDK_ROOT")
tasks.register("jarAndroid") {
dependsOn jar
doLast {
if (!sdkRoot || !new File(sdkRoot).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 desugaring
def dependencies = (configurations.compileClasspath.asList() + configurations.runtimeClasspath.asList() + [new File(platformRoot, "android.jar")]).collect{ "--classpath $it.path" }.join(" ")
def buildToolsRoot
if (project.hasProperty("buildToolsVersion"))
buildToolsRoot = new File("$sdkRoot/build-tools/${project.properties["buildToolsVersion"]}").absolutePath
else
buildToolsRoot = new File("$sdkRoot/build-tools/").listFiles().sort { x, y -> x.name <=> y.name }.first().absolutePath
//dex and desugar files - this requires d8 in your PATH
"env d8 $dependencies --min-api 14 --output ${jar.archiveBaseName.get()}Android.jar ${jar.archiveBaseName.get()}Desktop.jar"
.execute(["PATH=$buildToolsRoot:${System.getenv("PATH")}"], new File("$rootDir/build/libs/")).waitForProcessOutput(System.out, System.err)
}
}
tasks.register("deploy", Jar) {
dependsOn jar
dependsOn jarAndroid
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from { [ zipTree("$rootDir/build/libs/${jar.archiveBaseName.get()}Android.jar"), zipTree("$rootDir/build/libs/${jar.archiveBaseName.get()}Desktop.jar") ] }
}
tasks.named("build") {
dependsOn deploy
}
// test {
// useJUnitPlatform()
// testLogging {
// events "passed", "skipped", "failed"
// }
// }