-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
309 lines (282 loc) · 10 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
import me.modmuss50.mpp.ReleaseType
import org.groovymc.modsdotgroovy.types.core.Platform
plugins {
id 'maven-publish'
id 'signing'
id 'java-library'
alias libs.plugins.managedversioning
alias libs.plugins.modsdotgroovy
alias libs.plugins.modpublish
}
managedVersioning {
versionFile.set rootProject.file('version.properties')
metadataVersion.set libs.versions.minecraft
versionPRs()
versionSnapshots()
gitHubActions {
snapshot {
prettyName.set 'Snapshot'
workflowDispatch.set(true)
onBranches.add '1.*'
gradleJob {
name.set 'build'
javaVersion.set '21'
gradlew 'Build', 'build'
gradlew 'Publish', 'publish'
mavenSnapshot('github')
}
}
release {
prettyName.set 'Release'
workflowDispatch.set(true)
gradleJob {
name.set 'build'
javaVersion.set '21'
buildCache()
step {
setupGitUser()
}
readOnly.set false
gradlew 'Tag Release', 'tagRelease'
gradlew 'Build', 'build'
step {
run.set 'git push && git push --tags'
}
recordVersion 'Record Version', 'version'
sign()
mavenCentral()
modPublishing()
}
gradleJob {
name.set 'publishCentral'
javaVersion.set '21'
buildCache()
needs.add('build')
tag.set('${{needs.build.outputs.version}}')
gradlew 'Publish', 'publish', 'closeAndReleaseSonatypeStagingRepository'
sign()
mavenCentral()
modPublishing()
}
gradleJob {
name.set 'publishMod'
javaVersion.set '21'
buildCache()
needs.add('build')
tag.set('${{needs.build.outputs.version}}')
gradlew 'Publish', 'publishMods'
sign()
mavenCentral()
modPublishing()
}
gradleJob {
name.set 'publishJavadoc'
javaVersion.set '21'
buildCache()
needs.add('build')
tag.set('${{needs.build.outputs.version}}')
gradlew 'Build', 'combinedJavadoc'
step {
name.set 'Upload Javadoc'
uses.set 'andreiio/[email protected]'
with['args'] = 'copy build/prepareJavadoc r2:javadoc-lukebemish-dev'
env['RCLONE_CONFIG_R2_TYPE'] = 's3'
secret 'RCLONE_CONFIG_R2_ACCESS_KEY_ID', 'JAVADOC_ACCESS_KEY_ID'
secret 'RCLONE_CONFIG_R2_SECRET_ACCESS_KEY', 'JAVADOC_SECRET_ACCESS_KEY'
secret 'RCLONE_CONFIG_R2_ENDPOINT', 'JAVADOC_ENDPOINT'
env['RCLONE_CONFIG_R2_PROVIDER'] = 'Cloudflare'
env['RCLONE_CONFIG_R2_REGION'] = 'auto'
env['RCLONE_CONFIG_R2_ACL'] = 'private'
}
sign()
mavenCentral()
modPublishing()
}
}
build_pr {
prettyName.set 'Build PR'
pullRequest.set(true)
gradleJob {
name.set 'build'
javaVersion.set '21'
gradlew 'Build', 'build'
gradlew 'Publish', 'publish'
pullRequestArtifact()
}
}
publish_pr {
prettyName.set 'Publish PR'
publishPullRequestAction(
'github',
"${project.group.replace('.', '/')}/${project.name}",
'Build PR'
)
}
}
}
managedVersioning.apply()
println "Building: $version"
modsDotGroovy {
multiplatform.expose()
gather {
projectProperty('mod_id')
projectProperty('mod_name')
projectProperty('description')
}
}
sourceSets.neoforge.modsDotGroovy {
platform = Platform.NEOFORGE
inferGather.set false
multiplatform.from(':', 'main')
gather {
minecraftVersion = libs.versions.minecraft.get()
platformVersion = libs.versions.neoforge.get()
}
enable()
}
sourceSets.fabric.modsDotGroovy {
platform = Platform.FABRIC
inferGather.set false
multiplatform.from(':', 'main')
gather {
minecraftVersion = libs.versions.minecraft.get()
platformVersion = libs.versions.fabric.loader.get()
}
enable()
}
dependencies {
compileOnly cLibs.bundles.compileonly
annotationProcessor cLibs.bundles.annotationprocessor
compileOnly libs.fabric.mixin
fabricCompileOnly cLibs.bundles.compileonly
fabricAnnotationProcessor cLibs.bundles.annotationprocessor
modFabricImplementation libs.fabric.loader
modFabricImplementation libs.fabric.api
modFabricCompileOnly libs.owolib
neoforgeCompileOnly cLibs.bundles.compileonly
neoforgeAnnotationProcessor cLibs.bundles.annotationprocessor
}
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
java {
withSourcesJar()
withJavadocJar()
registerFeature("neoforge") {
usingSourceSet sourceSets.neoforge
capability(project.group as String, project.name, project.version as String)
capability(project.group as String, "$project.name-neoforge", project.version as String)
withSourcesJar()
withJavadocJar()
}
registerFeature("fabric") {
usingSourceSet sourceSets.fabric
capability(project.group as String, project.name, project.version as String)
capability(project.group as String, "$project.name-fabric", project.version as String)
withSourcesJar()
withJavadocJar()
}
}
managedVersioning.publishing.mavenCentral()
managedVersioning.publishing.mavenPullRequest(publishing)
managedVersioning.publishing.mavenSnapshot(publishing)
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
managedVersioning.publishing.sign(signing, it)
managedVersioning.publishing.pom(it, github_repo, license)
pom {
name = mod_name
description = project.description
}
}
}
}
['javadoc', 'fabricJavadoc', 'neoforgeJavadoc'].each {
tasks.named(it, Javadoc) {
include "**/api/**"
}
}
['sourcesJar', 'fabricSourcesJar', 'neoforgeSourcesJar'].each {
tasks.named(it, Jar) {
from(files("LICENSE")) {
rename { "${it}_${project.name}" }
}
}
}
['jar', 'fabricJar', 'neoforgeJar'].each {
tasks.named(it, Jar) {
from(files("LICENSE")) {
rename { "${it}_${project.name}" }
}
manifest {
attributes([
'Specification-Title' : mod_name,
'Specification-Vendor' : mod_author,
'Specification-Version' : project.version,
'Implementation-Title' : "$mod_name - ${project.name}",
'Implementation-Version' : project.version,
'Implementation-Vendor' : mod_author,
'Built-On-Minecraft' : libs.versions.minecraft.get(),
'Implementation-Commit-Time': managedVersioning.timestamp.get(),
'Implementation-Commit': managedVersioning.hash.get()
])
}
}
}
tasks.register('combinedJavadoc', Javadoc) {
source sourceSets.main.allJava
source sourceSets.fabric.allJava
source sourceSets.neoforge.allJava
def files = files()
[configurations.compileClasspath, configurations.fabricCompileClasspath, configurations.neoforgeCompileClasspath].each {
files.from it
dependsOn it
}
destinationDir = layout.buildDirectory.dir("prepareJavadoc/${(project.group as String).replace('.','/')}/${project.name}/${(project.version as String).split(/\./)[0]}").get().asFile
classpath = files
include "**/api/**"
}
tasks.named('assemble') {
dependsOn tasks.combinedJavadoc
}
def releaseType = ReleaseType.values().find { it.name() == project.release_type.toUpperCase(Locale.ROOT) } ?: ReleaseType.STABLE
publishMods {
changelog = ''
version = "${project.version}"
type = releaseType
dryRun = providers.environmentVariable("MODRINTH_KEY").getOrNull() == null || providers.environmentVariable("CURSEFORGE_KEY").getOrNull() == null
curseforge('curseforgeFabric') {
file = tasks.remapFabricJar.archiveFile
displayName = "${project.mod_name} [Fabric/Quilt] v${project.version}"
projectId = project.curseforge_id
accessToken = System.getenv('CURSEFORGE_KEY')
modLoaders = ['fabric', 'quilt']
minecraftVersions = [libs.versions.minecraft.get()]
requires('fabric-api')
}
curseforge('curseforgeNeoforge') {
file = tasks.remapNeoforgeJar.archiveFile
displayName = "${project.mod_name} [NeoForge] v${project.version}"
projectId = project.curseforge_id
accessToken = System.getenv('CURSEFORGE_KEY')
modLoaders = ['neoforge']
minecraftVersions = [libs.versions.minecraft.get()]
}
modrinth('modrinthFabric') {
file = tasks.remapFabricJar.archiveFile
displayName = "${project.mod_name} [Fabric/Quilt] v${project.version}"
projectId = project.modrinth_id
accessToken = System.getenv('MODRINTH_KEY')
minecraftVersions = [libs.versions.minecraft.get()]
modLoaders = ['fabric', 'quilt']
requires('fabric-api')
}
modrinth('modrinthNeoforge') {
file = tasks.remapNeoforgeJar.archiveFile
displayName = "${project.mod_name} [NeoForge] v${project.version}"
projectId = project.modrinth_id
accessToken = System.getenv('MODRINTH_KEY')
minecraftVersions = [libs.versions.minecraft.get()]
modLoaders = ['neoforge']
}
}