-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
150 lines (128 loc) · 3.72 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
@file:Suppress("UnstableApiUsage")
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import net.fabricmc.loom.task.AbstractRemapJarTask
import net.fabricmc.loom.task.RemapJarTask
plugins {
id("java")
id("idea")
alias(libs.plugins.fabricloom)
alias(libs.plugins.shadow)
alias(libs.plugins.modpublishplugin)
}
repositories {
mavenCentral()
exclusiveContent {
forRepository {
maven("https://maven.fabricmc.net/")
}
filter {
includeGroupAndSubgroups("net.fabricmc")
includeGroup("fabric-loom")
}
}
exclusiveContent {
forRepository {
maven("https://masa.dy.fi/maven")
}
filter {
includeGroup("carpet")
}
}
}
val modId: String by project
val modName: String by project
val modAuthor: String by project
val modVersion: String by project
val modDescription: String by project
val modUrl: String by project
val javaVersion: String by project
val javaToolchainVersion: String by project
val jarName: String by project
val compatibleMinecraftVersions: String by project
val curseProjectId: String by project
version = "${libs.versions.minecraft.get()}-$modVersion"
base {
archivesName.set(jarName)
}
java {
sourceCompatibility = JavaVersion.toVersion(javaVersion)
targetCompatibility = JavaVersion.toVersion(javaVersion)
toolchain.languageVersion = JavaLanguageVersion.of(javaToolchainVersion)
}
idea {
module {
isDownloadSources = true
isDownloadJavadoc = true
}
}
val shadowImplementation: Configuration by configurations.creating
configurations["shadowImplementation"].extendsFrom(configurations["implementation"])
configurations["compileClasspath"].extendsFrom(shadowImplementation)
dependencies {
minecraft(libs.minecraft.fabric)
mappings(loom.officialMojangMappings())
modImplementation(libs.fabric.loader)
modImplementation(libs.carpet.fabric)
shadowImplementation(libs.bigmath)
shadowImplementation(libs.apache.commons.compress)
}
loom {
accessWidenerPath = file("src/main/resources/kardexotools.accesswidener")
mixin.defaultRefmapName = "$modId.refmap.json"
}
tasks.named<ProcessResources>("processResources") {
val properties = mapOf(
"modVersion" to modVersion,
"modId" to modId,
"modName" to modName,
"modAuthor" to modAuthor,
"modDescription" to modDescription,
"modUrl" to modUrl,
"minecraftVersion" to libs.versions.minecraft.get()
)
inputs.properties(properties)
filesMatching(listOf("fabric.mod.json")) {
expand(properties)
}
}
val shadowJarTask = tasks.named<ShadowJar>("shadowJar") {
configurations = listOf(shadowImplementation)
from(sourceSets.main.get().output)
duplicatesStrategy = DuplicatesStrategy.INCLUDE
archiveClassifier = "dev"
isEnableRelocation = true
relocationPrefix = "net.kardexo.kardexotools.include"
}
tasks.named<AbstractRemapJarTask>("remapJar") {
dependsOn(shadowJarTask)
inputFile.set(shadowJarTask.get().archiveFile)
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(JavaLanguageVersion.of(javaVersion).asInt())
}
tasks.withType<Javadoc> {
with(options as StandardJavadocDocletOptions) {
addStringOption("Xdoclint:none", "-quiet")
}
}
tasks.withType<AbstractArchiveTask> {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
publishMods {
displayName = "$jarName-${libs.versions.minecraft.get()}-$modVersion"
file = tasks.named<RemapJarTask>("remapJar").get().archiveFile
changelog = provider { file("changelog.txt").readText() }
modLoaders.add("fabric")
type = STABLE
val compatibleVersions = compatibleMinecraftVersions.split(",")
curseforge {
projectId = curseProjectId
accessToken = findProperty("curse_api_key").toString()
minecraftVersions.set(compatibleVersions)
javaVersions.add(JavaVersion.toVersion(javaVersion))
clientRequired = false
serverRequired = true
}
}