-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
132 lines (106 loc) · 3.12 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
126
127
128
129
130
131
132
@file:Suppress("PropertyName")
import com.diffplug.gradle.spotless.SpotlessExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("fabric-loom") version "1.7-SNAPSHOT"
id("maven-publish")
kotlin("jvm") version "2.0.20"
id("com.diffplug.spotless") version "7.0.0.BETA2"
}
val gradle_version: String by project
val java_version: String by project
val mod_version: String by project
val maven_group: String by project
val archives_base_name: String by project
val access_widener_path: String by project
val minecraft_version: String by project
val minecraft_target_versions: String by project
val fabric_yarn_mappings: String by project
val fabric_loader_version: String by project
val fabric_loader_target_versions: String by project
val fabric_api_version: String by project
val fabric_kotlin_version: String by project
val palantir_java_format_version: String by project
val ktfmt_version: String by project
version = "$mod_version+$minecraft_version"
group = maven_group
base {
archivesName.set(archives_base_name)
}
dependencies {
minecraft("com.mojang", "minecraft", minecraft_version)
mappings("net.fabricmc", "yarn", fabric_yarn_mappings, classifier = "v2")
modImplementation("net.fabricmc", "fabric-loader", fabric_loader_version)
modImplementation("net.fabricmc.fabric-api", "fabric-api", fabric_api_version)
modImplementation("net.fabricmc", "fabric-language-kotlin", fabric_kotlin_version)
}
fabricApi {
configureDataGeneration()
}
loom {
accessWidenerPath = file(access_widener_path)
}
tasks.withType<ValidatePlugins>().configureEach {
failOnWarning.set(true)
enableStricterValidation.set(true)
}
tasks.named<Wrapper>("wrapper") {
gradleVersion = gradle_version
}
tasks.named<ProcessResources>("processResources") {
inputs.property("version", version)
filesMatching("fabric.mod.json") {
expand(
mapOf(
"version" to version,
"minecraft_target_versions" to minecraft_target_versions,
"fabric_loader_target_versions" to fabric_loader_target_versions,
)
)
}
}
tasks.named<JavaCompile>("compileJava") {
options.release = java_version.toInt()
}
tasks.named<KotlinCompile>("compileKotlin") {
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(java_version))
}
}
java {
withSourcesJar()
sourceCompatibility = JavaVersion.toVersion(java_version)
targetCompatibility = JavaVersion.toVersion(java_version)
}
tasks.named<Jar>("jar") {
from("LICENSE") {
rename {
"${it}_$archives_base_name"
}
}
}
extensions.configure<SpotlessExtension>("spotless") {
ratchetFrom("origin/main")
format("misc") {
target(
"*.gradle.*",
".editorconfig",
".git-blame-ignore-revs",
".gitignore",
"gradle.properties",
)
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
java {
palantirJavaFormat(palantir_java_format_version).style("GOOGLE").formatJavadoc(true)
}
kotlin {
ktfmt(ktfmt_version).googleStyle().configure {
it.setBlockIndent(2)
it.setContinuationIndent(4)
}
}
}