-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
197 lines (155 loc) · 4.11 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
//file:noinspection GrMethodMayBeStatic
//file:noinspection GradlePackageVersionRange
import static org.jetbrains.gradle.ext.ActionDelegationConfig.TestRunner
plugins {
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm'
id "org.jetbrains.gradle.plugin.idea-ext"
id 'com.diffplug.spotless'
id 'net.kyori.blossom'
alias(libs.plugins.quilt.loom)
}
archivesBaseName = project.archives_base_name
version = "${project.mod_version}+${libs.versions.minecraft.get()}"
group = project.maven_group
ext {
local = new File("./lib")
local.mkdir()
}
repositories {
flatDir {
dirs "./lib", "./.gradle/loom-cache/remapped_mods"
}
maven {
name 'Quilt'
url 'https://maven.quiltmc.org/repository/release'
}
maven {
name 'JitPack'
url 'https://jitpack.io'
}
mavenCentral()
}
dependencies {
minecraft libs.minecraft
mappings variantOf(libs.quilt.mappings) { classifier 'intermediary-v2' }
modImplementation libs.quilt.loader
modImplementation libs.quilted.fabric.api
modImplementation(libs.fabric.language.kotlin) {
exclude(group: "net.fabricmc")
}
if (!local.length()) {
modRuntimeOnly files("./lib")
}
}
task copyLocal(type: Copy) {
from("./lib")
into("./run/mods")
include("*.jar")
}
processResources.dependsOn copyLocal
loom {
accessWidenerPath = file("src/main/resources/${archives_base_name}.accesswidener")
}
compileJava {
options.encoding = "UTF-8"
sourceCompatibility = targetCompatibility = project.java_version
}
compileKotlin {
kotlinOptions {
jvmTarget = project.java_version
}
sourceCompatibility = targetCompatibility = project.java_version
}
java {
/*toolchain {
languageVersion = JavaLanguageVersion.of(project.java_version)
}*/
withSourcesJar()
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
}
}
spotless {
ratchetFrom "origin/${branch}"
java {
target 'src/*/java/**/*.java'
importOrder()
removeUnusedImports()
googleJavaFormat()
licenseHeader "/* ${expand_license(license_header)} */\n\n"
}
groovyGradle {
target '*.gradle'
greclipse()
}
kotlin {
ktlint(ktlint_version)
licenseHeader "/* ${expand_license(license_header)} */\n\n"
}
json {
target 'src/**/*.json'
simple()
}
format 'misc', {
target '*.md', '.gitignore'
trimTrailingWhitespace()
indentWithTabs()
endWithNewline()
}
}
compileJava.dependsOn spotlessApply
compileKotlin.dependsOn spotlessApply
blossom {
replaceToken('$[name]', project.property('mod_name'))
replaceToken('$[author]', project.property('mod_author'))
replaceToken('$[version]', project.property('mod_version'))
replaceToken('$[id]', project.property('archives_base_name'))
replaceToken('$[group]', project.property('maven_group'))
replaceToken('$[java]', project.property('java_version'))
replaceToken('$[kotlin]', project.property('kotlin_version'))
replaceToken('$[minecraft]', libs.versions.minecraft.get())
replaceToken('$[yarn]', libs.versions.quilt.mappings.get())
replaceToken('$[loader]', libs.versions.quilt.loader.get())
replaceToken('$[loom]', libs.versions.quilt.loom.get())
replaceToken('$[quilt]', libs.versions.quilted.fabric.api.get())
}
processResources {
filesMatching("*.json") {
expand([
"id" : project.archives_base_name,
"name" : project.mod_name,
"version" : project.version,
"author" : project.mod_author,
"desc" : project.mod_desc,
"site" : project.mod_site,
"src" : project.mod_src,
"minecraft": libs.versions.minecraft.get(),
"quilt" : ver(libs.versions.quilted.fabric.api),
"loader" : ver(libs.versions.quilt.loader),
"java" : project.java_version,
"adapter" : "1.7.4+kotlin.${kotlin_version}",
"group" : project.maven_group,
"license" : project.license_type,
])
}
}
idea.project.settings {
delegateActions {
delegateBuildRunToGradle = false
testRunner = TestRunner.PLATFORM
}
taskTriggers {
beforeSync project.getTasksByName("genSources", true)
}
}
String expand_license(String old) {
old = old.replace('\$DEVELOPER', mod_author)
old = old.replace('\$LICENSE', license_type.toUpperCase())
return old
}
String ver(Provider<?> provider) {
return provider.get().split("-").first()
}