-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
115 lines (100 loc) · 3.63 KB
/
build.gradle.kts
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
import cn.hutool.core.comparator.VersionComparator
import net.fabricmc.loom.LoomGradleExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.nio.file.Files
plugins {
`java-library`
`maven-publish`
id("agency.highlysuspect.minivan") version("0.5")
id("agency.highlysuspect.crossroad") version("0.3")
kotlin("jvm").version("2.0.20").apply(false)
id("fabric-loom").version(loomVersion).apply(false)
}
allprojects {
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "agency.highlysuspect.minivan")
apply(plugin = "agency.highlysuspect.crossroad")
base.archivesName = project.name
group = "io.github.xenfork"
version = "${project.name}-${modVersion}"
repositories {
mavenLocal()
mavenCentral()
maven("https://repo.spongepowered.org/repository/maven-public/")
}
}
subprojects {
dependencies {
compileOnly("org.projectlombok:lombok:1.18.34")
annotationProcessor("org.projectlombok:lombok:1.18.34")
}
}
val versions: String by project
versions.split(",").forEach {
val javaV = when {
VersionComparator.INSTANCE.compare(it, "1.17") < 0 -> {
8
}
VersionComparator.INSTANCE.compare(it, "1.18") < 0 -> {
16
}
VersionComparator.INSTANCE.compare(it, "1.20.5") < 0 -> {
17
}
else -> {
21
}
}
val javaT = if (javaV == 8) "JVM_1_8" else "JVM_$javaV"
project(":common-${it}") {
evaluationDependsOn(":api")
minivan {
version(it)
}
val javas = this.file("src/main/java/io/github/xenfork/mmpd/V${it.replace("1.", "").replace(".", "_")}").toPath()
val resources = this.file("src/main/resources").toPath()
Files.createDirectories(javas)
Files.createDirectories(resources)
java {
withSourcesJar()
sourceCompatibility = if (javaV == 8) JavaVersion.VERSION_1_8 else JavaVersion.toVersion(javaV)
targetCompatibility = if (javaV == 8) JavaVersion.VERSION_1_8 else JavaVersion.toVersion(javaV)
toolchain {
languageVersion.set(JavaLanguageVersion.of(javaV))
}
}
dependencies {
implementation(project(":api"))
}
}
project(":fabric-${it}") {
apply(plugin = "fabric-loom")
apply(plugin = "org.jetbrains.kotlin.jvm")
evaluationDependsOn(":common-${it}")
val javas = this.file("src/main/java/io/github/xenfork/mmpd/fabric/V${it.replace("1.", "").replace(".", "_")}").toPath()
val resources = this.file("src/main/resources").toPath()
Files.createDirectories(javas)
Files.createDirectories(resources)
tasks.withType<JavaCompile> {
options.release.set(javaV)
}
tasks.withType<KotlinCompile> {
compilerOptions.jvmTarget.set(JvmTarget.valueOf(javaT))
}
java {
withSourcesJar()
sourceCompatibility = if (javaV == 8) JavaVersion.VERSION_1_8 else JavaVersion.toVersion(javaV)
targetCompatibility = if (javaV == 8) JavaVersion.VERSION_1_8 else JavaVersion.toVersion(javaV)
toolchain {
languageVersion.set(JavaLanguageVersion.of(javaV))
}
}
dependencies {
"minecraft"("com.mojang:minecraft:${it}")
"mappings"(LoomGradleExtension.get(project).officialMojangMappings())
"modImplementation"("net.fabricmc:fabric-language-kotlin:${kotlinLanguageVersion}")
}
}
}