-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
280 lines (249 loc) · 9.18 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
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net/' }
maven { // PARCHMENT
url = "https://maven.parchmentmc.org"
}
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.0.+', changing: true
classpath "gradle.plugin.com.matthewprenger:CurseGradle:1.4.0"
classpath "org.ajoberstar.grgit:grgit-gradle:5.3.0"
classpath 'org.parchmentmc:librarian:1.+'
}
}
plugins {
id "com.modrinth.minotaur" version "2.+"
// It's safest to have this on 2.+ to get the latest features and
// bug fixes without having to worry about breaking changes.
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'com.matthewprenger.cursegradle'
apply plugin: 'org.ajoberstar.grgit'
apply from: "https://moddingtutorials.org/applesilicon.gradle"
def branch = grgit.branch.current()
println "On branch: ${branch.fullName}"
println "Pipeline branch: " + (System.getenv('CI_COMMIT_BRANCH') ?: 'NONE')
group = 'com.sweetrpg'
archivesBaseName = "${project.name}-${project.target_mc_version}"
version = System.getenv("MOD_VERSION") ?: new File(".release-info/1.18/VERSION").text.trim()
println "Project version: ${version}"
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
sourceSets {
api
main {
compileClasspath += sourceSets.api.output
runtimeClasspath += sourceSets.api.output
resources.srcDirs += 'src/generated/resources'
}
test {
compileClasspath += sourceSets.api.output
runtimeClasspath += sourceSets.api.output
}
}
configurations {
apiImplementation.extendsFrom(implementation)
apiRuntimeOnly.extendsFrom(runtimeOnly)
}
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
repositories {
maven { // JEI
url "https://dvs1.progwml6.com/files/maven"
content { includeGroup "mezz.jei" }
}
maven { // The One Probe
url "https://cursemaven.com"
}
maven { // ???
url 'https://maven.blamejared.com'
}
}
minecraft {
mappings channel: 'parchment', version: project.parchment_version
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs {
client {
taskName 'client'
workingDirectory file('run')
property 'forge.logging.console.level', 'debug'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
mods {
create(mod_id) {
source(sourceSets.main)
source(sourceSets.api)
}
}
}
server {
taskName 'server'
workingDirectory file('run-server')
property 'forge.logging.console.level', 'debug'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
mods {
create(mod_id) {
source(sourceSets.main)
source(sourceSets.api)
}
}
}
data {
taskName 'data'
workingDirectory file('run')
property 'forge.logging.console.level', 'debug'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
args '--mod', project.mod_id, '--all', '--output', '"' + file('src/generated/resources/') + '"', '--existing', '"' + sourceSets.main.resources.srcDirs[0] + '"'
mods {
create(mod_id) {
source(sourceSets.main)
source(sourceSets.api)
}
}
}
}
}
dependencies {
minecraft "net.minecraftforge:forge:${project.forge_version}"
compileOnly fg.deobf("mezz.jei:jei-${jei_version}:api")
runtimeOnly fg.deobf("mezz.jei:jei-${jei_version}")
runtimeOnly fg.deobf("curse.maven:doggytalents-${dt_project_id}:${dt_file_id}")
compileOnly fg.deobf("vazkii.patchouli:Patchouli:${ptch_version}:api")
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${ptch_version}")
// implementation fg.deobf("curse.maven:farmers-delight-398521:${fd_file_id}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${jupiter_version}")
testImplementation("org.junit.jupiter:junit-jupiter-api:${jupiter_version}")
runtimeOnly fg.deobf("curse.maven:the-one-probe-245211:${top_file_id}")
}
// Define a task to create a jar of project sources
task sourcesJar(type: Jar) {
duplicatesStrategy(DuplicatesStrategy.FAIL)
archiveClassifier = 'sources'
from sourceSets.main.allJava
from sourceSets.api.allJava
}
// Define a task to create a jar for the API code
task apiJar(type: Jar) {
duplicatesStrategy(DuplicatesStrategy.FAIL)
archiveClassifier = 'api'
from sourceSets.api.output
from sourceSets.api.allJava
}
// Add the sources and API jars to the list of generated artifacts
artifacts {
archives sourcesJar
archives apiJar
}
def replaceResources = tasks.register('replaceResources', Copy) {
it.outputs.upToDateWhen { false }
it.from(sourceSets.main.resources) {
include 'META-INF/mods.toml'
expand([
'version': project.version,
'minecraft_version_range': project.minecraft_version_range,
'forge_version_range': project.forge_version_range,
'fml_version_range': project.fml_version_range,
])
}
it.into "$buildDir/resources/main/"
}
processResources {
duplicatesStrategy(DuplicatesStrategy.INCLUDE) // .FAIL
exclude('META-INF/mods.toml')
configure { finalizedBy(replaceResources) }
}
classes.configure {
dependsOn(replaceResources)
}
jar {
from sourceSets.main.output
from sourceSets.api.output
manifest {
attributes([
"Specification-Title": "Cat Herder",
"Specification-Vendor": "SweetRPG",
"Specification-Version": project.version, // "1",
"Implementation-Title": project.name,
"Implementation-Version": project.version,
"Implementation-Vendor" :"SweetRPG",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
test {
useJUnitPlatform()
}
curseforge {
apiKey = System.getenv('CURSEFORGE_API_KEY') ?: 0
project {
id = project.curseforge_project_id
changelog = file("CHANGELOG/${project.base_mc_version}/current.md")
changelogType = 'markdown'
releaseType = findProperty("curseforge_release_type") ?: 'beta'
addGameVersion project.target_mc_version
// for (String v : project.additional_mc_versions.split(',')) {
// if (v) {
// addGameVersion v
// }
// }
addArtifact apiJar
relations {
optionalDependency 'autumnity'
optionalDependency 'biomes-o-plenty'
optionalDependency 'botania'
optionalDependency 'configured'
optionalDependency 'farmers-delight'
optionalDependency 'itemphysic'
optionalDependency 'jei'
optionalDependency 'patchouli'
}
}
options {
detectNewerJava = true
}
}
modrinth {
token = System.getenv("MODRINTH_API_KEY")
projectId = project.modrinth_project_id
versionNumber = project.version
versionType = project.modrinth_release_type
uploadFile = jar
additionalFiles = [apiJar]
gameVersions = [project.target_mc_version] // Must be an array, even with only one version
changelog = file("CHANGELOG/${project.base_mc_version}/current.md").text
loaders = ["forge"] // Must also be an array - no need to specify this if you're using Loom or ForgeGradle
dependencies { // A special DSL for creating dependencies
// scope.type
// The scope can be `required`, `optional`, `incompatible`, or `embedded`
// The type can either be `project` or `version`
// required.project "fabric-api" // Creates a new required dependency on Fabric API
optional.project "autumnity"
optional.project "biomes-o-plenty"
optional.project "botania"
optional.project "configured"
optional.project "farmers-delight"
optional.project "itemphysic"
optional.project "jei"
optional.project "patchouli"
}
}
// Must be done in afterEvaluate as the specific curseforge$id
// task is generated lazily
afterEvaluate {
// tasks.named("curseforge${project.curseforge_project_id}").get().dependsOn.add(makeChangelog)
}
if (project.hasProperty('UPDATE_MAPPINGS')) {
extractRangeMap {
sources sourceSets.api.java.srcDirs
}
applyRangeMap {
sources sourceSets.api.java.srcDirs
}
sourceSets.api.java.srcDirs.each { extractMappedNew.addTarget it }
}