-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
125 lines (99 loc) · 3.45 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
116
117
118
119
120
121
122
123
124
125
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
kotlin("jvm") version "2.0.20"
id("fabric-loom") version "1.9-SNAPSHOT"
}
loom {
serverOnlyMinecraftJar()
accessWidenerPath = file("src/main/resources/minekord.accesswidener")
}
val modVersion: String by project
val mavenGroup: String by project
base.archivesName.set("minekord")
version = "$modVersion+${libs.versions.minecraft.get()}"
group = mavenGroup
repositories {
maven("https://maven.nucleoid.xyz")
maven("https://snapshots-repo.kordex.dev")
maven("https://repo.kord.dev/snapshots")
}
val includeImplementation: Configuration by configurations.creating {
configurations.implementation.configure { extendsFrom(this@creating) }
}
dependencies {
minecraft(libs.minecraft)
mappings(libs.yarn)
modImplementation(libs.fabric.loader)
modImplementation(libs.fabric.kotlin)
modImplementation(libs.fabric.api)
includeImplementation(libs.kordex)
includeImplementation(libs.konf.core)
includeImplementation(libs.konf.toml)
implementAndInclude(libs.discord.reserializer)
implementAndInclude(libs.simple.ast)
implementAndInclude(libs.kyori)
implementAndInclude(libs.placeholder.api)
modCompileOnly(libs.luckperms)
implementAndInclude(libs.permissions)
}
afterEvaluate {
dependencies {
handleIncludes(includeImplementation)
}
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
withSourcesJar()
}
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
}
}
tasks {
processResources {
inputs.property("version", modVersion)
filesMatching("fabric.mod.json") {
expand(
"version" to modVersion
)
}
}
jar {
from("LICENSE")
}
}
/* Thanks to https://github.com/jakobkmar for original script */
fun DependencyHandlerScope.includeTransitive(
dependencies: Set<ResolvedDependency>,
minecraftLibs: Set<ResolvedDependency>,
kotlinDependency: ResolvedDependency,
checkedDependencies: MutableSet<ResolvedDependency> = HashSet()
) {
dependencies.forEach {
if (checkedDependencies.contains(it) || it.moduleGroup == "org.jetbrains.kotlin" || it.moduleGroup == "org.jetbrains.kotlinx") return@forEach
if (kotlinDependency.children.any { dep -> dep.name == it.name }) {
println("Skipping -> ${it.name} (already in fabric-language-kotlin)")
} else if (minecraftLibs.any { dep -> dep.moduleGroup == it.moduleGroup && dep.moduleName == it.moduleName }) {
println("Skipping -> ${it.name} (already in minecraft)")
} else {
include(it.name)
println("Including -> ${it.name}")
}
checkedDependencies += it
includeTransitive(it.children, minecraftLibs, kotlinDependency, checkedDependencies)
}
}
fun DependencyHandlerScope.handleIncludes(configuration: Configuration) {
includeTransitive(
configuration.resolvedConfiguration.firstLevelModuleDependencies,
configurations.minecraftLibraries.get().resolvedConfiguration.firstLevelModuleDependencies,
configurations.modImplementation.get().resolvedConfiguration.firstLevelModuleDependencies
.first { it.moduleGroup == "net.fabricmc" && it.moduleName == "fabric-language-kotlin" },
)
}
fun DependencyHandlerScope.implementAndInclude(dep: Any) {
modImplementation(dep)
include(dep)
}