generated from alex5nader/Fabric-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
201 lines (167 loc) · 5.27 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
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
198
199
200
201
@file:Suppress("UnstableApiUsage")
import java.util.Properties
import net.fabricmc.loom.task.RemapJarTask
import com.modrinth.minotaur.TaskModrinthUpload
import com.matthewprenger.cursegradle.CurseArtifact
import com.matthewprenger.cursegradle.CurseProject
import com.matthewprenger.cursegradle.CurseRelation
import com.matthewprenger.cursegradle.Options
plugins {
java
`java-library`
id("fabric-loom").version(Fabric.Loom.version)
`maven-publish`
id("com.matthewprenger.cursegradle").version("1.4.0")
id("com.modrinth.minotaur").version("1.1.0")
}
base.archivesBaseName = PickUp.name
group = PickUp.group
version = PickUp.version
configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
val apiKeys by lazy {
Properties().apply { load(file("apiKeys.properties").inputStream()) }
}
repositories {
mavenLocal { name = "Maven Local" }
maven(url = "https://maven.fabricmc.net/") { name = "Fabric" }
maven(url = "https://maven.pkg.github.com/alex5nader/Server-Config") {
name = "Server Config"
content {
includeGroup("dev.alexnader")
}
credentials {
username = "alex5nader"
password = apiKeys.getProperty("githubPackagesToken")
}
}
maven(url = "https://cursemaven.com/") {
name = "Curse Maven"
content {
includeGroup("curse.maven")
}
}
maven(url = "https://jitpack.io/") {
name = "JitPack"
}
}
dependencies {
minecraft(Minecraft.coordinate)
mappings(Fabric.yarn.coordinate)
deps.forEach {
modImplementation(it.coordinate) {
if (it.group != Fabric.api.group) {
exclude(group = Fabric.api.group)
}
if (!it.transitive) {
isTransitive = false
}
}
}
jijDeps.forEach { include(it.coordinate) }
runtimeDeps.forEach { modRuntime(it.coordinate) }
implementation(Gson.coordinate)
compileOnly(Jsr305.coordinate)
}
object Meta {
val changelogLink =
"See https://github.com/alex5nader/${PickUp.name}/milestones for a list of changelogs."
val minecraftVersions = listOf(
"1.16.4"
)
val modVersionName = "Version ${PickUp.version}"
}
tasks.getByName<ProcessResources>("processResources") {
inputs.properties("version" to PickUp.version)
filesMatching("fabric.mod.json") {
expand(
"modId" to PickUp.modId,
"modVersion" to PickUp.version,
"modName" to PickUp.name,
"modPrettyName" to PickUp.prettyName,
"fapiVersion" to Fabric.api.version,
"mcVersions" to Meta.minecraftVersions.joinToString("\",\"")
)
}
filesMatching("mixins.${PickUp.modId}.json") {
expand("modId" to PickUp.modId)
}
}
val remapJar = tasks.getByName<RemapJarTask>("remapJar")
publishing {
repositories {
maven(url = "maven.pkg.github.com/alex5nader/${PickUp.name}") {
name = "GitHub_Packages"
credentials {
username = "alex5nader"
password = System.getenv("GITHUB_TOKEN")
}
}
}
publications.create<MavenPublication>("maven") {
artifactId = PickUp.version
artifact(remapJar) {
classifier = null
builtBy(remapJar)
}
}
}
val publishModrinth = tasks.create<TaskModrinthUpload>("publishModrinth") {
val modrinthApiKey: String by apiKeys
token = modrinthApiKey
projectId = PickUp.modrinthId
changelog = Meta.changelogLink
versionNumber = PickUp.version
versionName = Meta.modVersionName
releaseType = "release"
uploadFile = remapJar
Meta.minecraftVersions.forEach(this::addGameVersion)
addLoader("fabric")
}
curseforge {
val curseforgeApiKey: String by apiKeys
apiKey = curseforgeApiKey
project(closureOf<CurseProject> {
id = PickUp.curseforgeId
mainArtifact(remapJar)
releaseType = "release"
Meta.minecraftVersions.forEach(this::addGameVersion)
addGameVersion("Fabric")
relations(closureOf<CurseRelation> {
jijDeps.forEach { dep ->
dep.curseforgeSlug
.takeIf { dep.referenceOnCurseforge }
?.let {
embeddedLibrary(it)
}
}
deps.forEach { dep ->
dep.curseforgeSlug
.takeIf { dep.referenceOnCurseforge }
?.takeIf { dep !in jijDeps }
?.let {
requiredDependency(it)
}
}
runtimeDeps.forEach { dep ->
dep.curseforgeSlug
.takeIf { dep.referenceOnCurseforge }
?.let {
optionalDependency(it)
}
}
})
changelog = Meta.changelogLink
mainArtifact(
file("${project.buildDir}/libs/${base.archivesBaseName}-$version.jar"),
closureOf<CurseArtifact> {
displayName = Meta.modVersionName
}
)
})
options(closureOf<Options> {
forgeGradleIntegration = false
})
}