-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
115 lines (91 loc) · 3.88 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
@file:Suppress("GradlePackageVersionRange")
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val transitiveInclude: Configuration by configurations.creating
fun DependencyHandlerScope.includeTransitive(
root: ResolvedDependency?,
dependencies: Set<ResolvedDependency>,
fabricLanguageKotlinDependency: ResolvedDependency,
checkedDependencies: MutableSet<ResolvedDependency> = HashSet()
) {
dependencies.forEach {
if (checkedDependencies.contains(it) || (it.moduleGroup == "org.jetbrains.kotlin" && it.moduleName.startsWith("kotlin-stdlib")) || (it.moduleGroup == "org.slf4j" && it.moduleName == "slf4j-api"))
return@forEach
if (fabricLanguageKotlinDependency.children.any { kotlinDep -> kotlinDep.name == it.name }) {
println("Skipping -> ${it.name} (already in fabric-language-kotlin)")
} else {
include(it.name)
println("Including -> ${it.name} from ${root?.name}")
}
checkedDependencies += it
includeTransitive(root ?: it, it.children, fabricLanguageKotlinDependency, checkedDependencies)
}
}
// from : https://github.com/StckOverflw/TwitchControlsMinecraft/blob/4bf406893544c3edf52371fa6e7a6cc7ae80dc05/build.gradle.kts
fun DependencyHandlerScope.handleIncludes(project: Project, configuration: Configuration) {
includeTransitive(
null,
configuration.resolvedConfiguration.firstLevelModuleDependencies,
project.configurations.getByName("modImplementation").resolvedConfiguration.firstLevelModuleDependencies
.first { it.moduleGroup == "net.fabricmc" && it.moduleName == "fabric-language-kotlin" }
)
}
plugins {
id("fabric-loom") version "0.12-SNAPSHOT"
id("org.jetbrains.kotlin.jvm") version "1.7.10"
id("org.jetbrains.kotlin.plugin.serialization") version "1.7.10"
idea
}
val archivesBaseName = property("archives_base_name")
group = property("maven_group")!!
version = property("mod_version")!!
repositories {
mavenCentral()
mavenLocal()
maven("https://repo.repsy.io/mvn/amibeskyfy16/repo")
}
dependencies {
minecraft("com.mojang:minecraft:${properties["minecraft_version"]}")
mappings("net.fabricmc:yarn:${properties["yarn_mappings"]}:v2")
modImplementation("net.fabricmc:fabric-loader:${properties["loader_version"]}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${properties["fabric_version"]}")
modImplementation("net.fabricmc:fabric-language-kotlin:${properties["fabric_kotlin_version"]}")
transitiveInclude(implementation("ch.skyfy.jsonconfig:json-config:2.1")!!)
handleIncludes(project, transitiveInclude)
testImplementation("org.jetbrains.kotlin:kotlin-test:1.7.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.8.2")
testImplementation("org.junit.platform:junit-platform-runner:1.8.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
}
tasks {
val javaVersion = JavaVersion.VERSION_17
processResources {
inputs.property("version", project.version)
filteringCharset = "UTF-8"
filesMatching("fabric.mod.json") {
expand(mutableMapOf("version" to project.version))
}
}
java {
withSourcesJar()
}
named<KotlinCompile>("compileKotlin") {
kotlinOptions.jvmTarget = javaVersion.toString()
}
named<JavaCompile>("compileJava") {
options.encoding = "UTF-8"
options.release.set(javaVersion.toString().toInt())
}
named<Jar>("jar") {
from("LICENSE") {
rename { "${it}_${archivesBaseName}" }
}
}
named<Test>("test") {
useJUnitPlatform()
testLogging {
outputs.upToDateWhen { false } // When the build task is executed, stderr-stdout of test classes will be show
showStandardStreams = true
}
}
}