-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
200 lines (182 loc) · 5.59 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
import org.groovymc.modsdotgroovy.types.core.Platform
plugins {
id 'maven-publish'
id 'signing'
id 'java-library'
alias libs.plugins.managedversioning
alias libs.plugins.modsdotgroovy
}
managedVersioning {
versionFile.set project.file('version.properties')
metadataVersion.set libs.versions.minecraft
versionPRs()
versionSnapshots()
gitHubActions {
snapshot {
prettyName.set 'Snapshot'
workflowDispatch.set(true)
onBranches.add '1.*'
gradleJob {
buildCache()
name.set 'build'
javaVersion.set '21'
gradlew 'Build', 'build'
gradlew 'Publish', 'publish'
mavenSnapshot('github')
}
}
release {
prettyName.set 'Release'
workflowDispatch.set(true)
gradleJob {
buildCache()
name.set 'build'
javaVersion.set '21'
step {
setupGitUser()
}
readOnly.set false
gradlew 'Tag Release', 'tagRelease'
gradlew 'Build', 'build'
step {
run.set 'git push && git push --tags'
}
recordVersion 'Record Version', 'version'
}
gradleJob {
buildCache()
name.set 'publish'
javaVersion.set '21'
needs.add('build')
tag.set('${{needs.build.outputs.version}}')
gradlew 'Publish', 'publish', 'closeAndReleaseSonatypeStagingRepository'
mavenCentral()
mavenStaging('github')
sign()
}
}
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
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.mavenStaging(publishing)
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
}
}
}
}
['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()
])
}
}
}