-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuild.gradle
308 lines (255 loc) · 7.56 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
plugins {
id('net.minecraftforge.gradle') version '6.+'
id('idea')
id("maven-publish")
id('com.modrinth.minotaur') version '2.+'
id('com.matthewprenger.cursegradle') version '1.4.0'
id('org.parchmentmc.librarian.forgegradle') version "1.+"
id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.9"
}
group = "thedarkcolour.forestry"
version = forestryVersion
archivesBaseName = "forestry-$minecraftVersion"
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
minecraft {
mappings channel: 'parchment', version: "$mappingsVersion-$minecraftVersion"
accessTransformer = file("src/main/resources/META-INF/accesstransformer.cfg")
runs {
configureEach {
workingDirectory project.file("run")
property "forge.logging.console.level", "debug"
property "fml.earlyprogresswindow", "false"
// See https://github.com/Vazkii/Patchouli#mixin-troubleshooting
property "mixin.env.remapRefMap", "true"
property "mixin.env.refMapRemappingFile", "$projectDir/build/createSrgToMcp/output.srg"
mods {
forestry {
source sourceSets.main
}
}
}
client {}
server {
workingDirectory project.file("run/server")
}
data {
args "--mod", "forestry", "--all", "--output", file("src/generated/resources/"), "--existing", file("src/main/resources/")
}
}
}
repositories {
maven {
name = 'jei'
url = 'https://maven.blamejared.com/'
content { includeGroup "mezz.jei" }
}
maven {
name = "Patchouli"
url = "https://maven.blamejared.com/"
}
maven {
name = 'Architectury API'
url = "https://maven.architectury.dev"
content { includeGroup "dev.architectury" }
}
maven {
name = 'KubeJS and Rhino'
url = "https://maven.saps.dev/minecraft"
content { includeGroup "dev.latvian.mods" }
}
maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}
maven {
name = 'ModKit'
url 'https://jitpack.io'
content { includeGroup 'com.github.thedarkcolour' }
}
}
dependencies {
minecraft "net.minecraftforge:forge:$minecraftVersion-$forgeVersion"
// JEI OPTIONAL
compileOnly fg.deobf("mezz.jei:jei-$minecraftVersion-common-api:$jeiVersion")
compileOnly fg.deobf("mezz.jei:jei-$minecraftVersion-forge-api:$jeiVersion")
runtimeOnly fg.deobf("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion")
// KubeJS OPTIONAL
implementation fg.deobf("dev.architectury:architectury-forge:${architectury_version}")
implementation fg.deobf("dev.latvian.mods:rhino-forge:${rhino_version}")
implementation fg.deobf("dev.latvian.mods:kubejs-forge:${kubejs_version}")
// PATCHOULI REQUIRED
compileOnly fg.deobf("vazkii.patchouli:Patchouli:$patchouliVersion-FORGE:api")
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:$patchouliVersion-FORGE")
// ModKit DEV ONLY
implementation fg.deobf('com.github.thedarkcolour:ModKit:0302f9aa42')
}
sourceSets.main.resources { srcDir 'src/generated/resources' }
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
var replaceProperties = [
"version": project.version,
"forgeVersionRange": forgeVersionRange,
"jeiVersionRange": jeiVersionRange,
"patchouliVersionRange": patchouliVersionRange,
"fmlVersionRange": fmlVersionRange,
]
inputs.properties replaceProperties
expand replaceProperties
from "src/main/templates"
into "build/generated/sources/modMetadata"
}
sourceSets.main.resources.srcDir generateModMetadata
idea.project.settings {
taskTriggers {
afterSync generateModMetadata
}
}
jar {
finalizedBy "reobfJar"
from sourceSets.main.output.classesDirs
from sourceSets.main.output.resourcesDir
manifest {
attributes([
"Specification-Title" : "Forestry",
"Specification-Vendor" : "SirSengir",
"Specification-Version" : "${project.version}",
"Implementation-Title" : "${project.name}",
"Implementation-Version" : "${project.version}",
"Implementation-Vendor" : "SirSengir",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.compilerArgs << "-Xmaxerrs" << "400"
}
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}
javadoc {
source = sourceSets.main.allJava
classpath = sourceSets.main.compileClasspath + sourceSets.main.output
options.addStringOption("Xdoclint:none", "-quiet")
options.encoding = "UTF-8"
include "forestry/api/**"
}
tasks.register('javadocJar', Jar) {
dependsOn javadoc
archiveClassifier.set("javadoc")
from javadoc.destinationDir
}
tasks.register('sourcesJar', Jar) {
archiveClassifier.set("sources")
from sourceSets.main.allJava
}
tasks.register('apiJar', Jar) {
archiveClassifier.set("api")
// api jar ist just a development aid and serves as both a binary and source jar simultaneously
from sourceSets.main.output
from sourceSets.main.allJava
include "forestry/api/**"
}
artifacts {
archives javadocJar
archives sourcesJar
archives apiJar
}
publishing {
afterEvaluate {
publications {
mavenJava(MavenPublication) {
groupId = project.group
artifactId = project.archivesBaseName
version = project.version
// ForgeGradle will generate wild dependency definitions, see https://github.com/MinecraftForge/ForgeGradle/issues/584
// Since we don't actually depend on anything, just remove the entire node.
pom.withXml {
asNode().remove(asNode().dependencies)
}
from components.java
artifact sourcesJar
artifact javadocJar
artifact apiJar
}
}
}
repositories {
maven {
def releasesRepoUrl = uri("$buildDir/repos/releases")
def snapshotsRepoUrl = uri("$buildDir/repos/snapshots")
name = "Project"
url = version.toString().endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl
}
maven {
credentials {
username System.getenv("MODMAVEN_USER")
password System.getenv("MODMAVEN_PASSWORD")
}
name = "Modmaven"
url = "https://modmaven.dev/artifactory/local-releases/"
}
}
}
if (System.getenv("CURSEFORGE_TOKEN")) {
curseforge {
apiKey = System.getenv("CURSEFORGE_TOKEN")
project {
id = project.curseforgeId
changelogType = "markdown"
changelog = getChangelog(version)
releaseType = "release"
addGameVersion(project.minecraftVersion)
addGameVersion("Forge")
addGameVersion("Java 17")
mainArtifact(jar.archiveFile) {
displayName = "Forestry: Community Edition ${project.version}"
relations {
optionalDependency 'jei'
requiredDependency 'patchouli'
}
}
}
}
}
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = project.modrinthId
versionName = "Forestry: Community Edition $version"
versionNumber = version.toString()
versionType = "release"
gameVersions = [minecraftVersion]
loaders = ["forge"]
changelog = getChangelog(project.version)
uploadFile = jar
additionalFiles.add(sourcesJar)
additionalFiles.add(apiJar)
additionalFiles.add(javadocJar)
dependencies {
optional.project("jei")
required.project("patchouli")
}
}
static def getChangelog(Object version) {
version = version.toString()
def file = new File('changelog.md')
if (!file.exists()) {
return "Changelog file not found"
}
// Relies on the changelog block being "##blahblahblah_VERSION" where _ is a space
def content = file.text.normalize().split("##.* ")
for (final def chunk in content) {
if (chunk.isEmpty()) continue
def lineTerminatorIndex = chunk.findIndexOf { c -> c == '\n' || c == '\r' }
def versionString = chunk.substring(0, lineTerminatorIndex)
if (versionString == version) {
return "## Forestry $version\n" + chunk.substring(lineTerminatorIndex + 1)
}
}
// Fallback in case this fails
return "Forestry Update ${version}"
}