-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
139 lines (107 loc) · 4.01 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
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.guardsquare:proguard-gradle:7.6.0"
}
}
plugins {
id "org.jetbrains.kotlin.jvm" version "2.0.10"
// id "com.gradleup.gr8" version "0.10"
}
apply plugin: "java"
version '1.0'
targetCompatibility = 8
sourceCompatibility = JavaVersion.VERSION_16
sourceSets.main.java.srcDirs = ["src"]
sourceSets.main.kotlin.srcDirs = ["src"]
repositories{
mavenCentral()
maven{ url "https://raw.githubusercontent.com/Zelaux/MindustryRepo/master/repository" }
maven{ url 'https://www.jitpack.io' }
}
ext{
//the build number that this mod is made for
mindustryVersion = 'v146'
jabelVersion = "93fde537c7"
sdkRoot = System.getenv("ANDROID_HOME") ?: System.getenv("ANDROID_SDK_ROOT")
}
//java 8 backwards compatibility flag
allprojects{
tasks.withType(JavaCompile){
options.compilerArgs.addAll(['--release', '8'])
}
}
dependencies{
compileOnly "com.github.Anuken.Arc:arc-core:$mindustryVersion"
compileOnly "com.github.Anuken.Mindustry:core:$mindustryVersion"
annotationProcessor "com.github.Anuken:jabel:$jabelVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib"
}
tasks.register('jarAndroid') {
dependsOn minimize
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(" ")
//dex and desugar files - this requires d8 in your PATH
"d8 $dependencies --min-api 14 --output FloodCompatAndroid.jar FloodCompatDesktop.jar"
.execute(null, new File("$buildDir/libs")).waitForProcessOutput(System.out, System.err)
}
}
jar{
archiveFileName = "FloodCompatUnshrunk.jar"
from{
configurations.runtimeClasspath.collect{ it.isDirectory() ? it : zipTree(it) }
}
from(rootDir){
include "mod.hjson"
}
from("assets/"){
include "**"
}
}
tasks.register("deploy", Jar){
dependsOn jarAndroid
dependsOn minimize
archiveFileName = "FloodCompat.jar"
from{ [zipTree("$buildDir/libs/FloodCompatDesktop.jar"), zipTree("$buildDir/libs/FloodCompatAndroid.jar")] }
doLast{
delete{
delete "$buildDir/libs/FloodCompatDesktop.jar"
delete "$buildDir/libs/FloodCompatAndroid.jar"
}
}
}
kotlin.compilerOptions {
jvmTarget = JvmTarget.JVM_1_8
freeCompilerArgs.add("-Xjdk-release=1.8")
}
tasks.register("minimize", proguard.gradle.ProGuardTask) { // We shrink because of kotlin being >1MB
dependsOn jar
injars "build/libs/FloodCompatUnshrunk.jar", filter: '!module-info.class,!META-INF/**,!**.kotlin_builtins'
outjars "build/libs/FloodCompatDesktop.jar"
// Automatically handle the Java version of this build.
if (System.getProperty('java.version').startsWith('1.')) {
// Before Java 9, the runtime classes were packaged in a single jar file.
libraryjars "${System.getProperty('java.home')}/lib/rt.jar"
} else {
// As of Java 9, the runtime classes are packaged in modular jmod files.
libraryjars "${System.getProperty('java.home')}/jmods/java.base.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
}
configuration "rules.pro"
}
//gr8 {
// var shadowedJar = create("gr8") {
// proguardFile("rules.pro")
// configuration("shade")
// }
//
// replaceOutgoingJar(shadowedJar)
//
//// removeGradleApifromapi()
//}