-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
215 lines (177 loc) · 5.4 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
plugins {
id 'net.minecraftforge.gradle' version '6.+'
id 'idea'
id "maven-publish"
id "org.parchmentmc.librarian.forgegradle" version "1.+"
id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.9"
id('com.modrinth.minotaur') version '2.+'
id('com.matthewprenger.cursegradle') version '1.4.0'
}
group = "thedarkcolour.gendustry"
version = gendustryVersion
base.archivesName = "gendustry-$minecraftVersion"
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
minecraft {
mappings channel: 'parchment', version: "$mappingsVersion-$minecraftVersion"
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"
// Requires JetBrains JDK or DCEVM
jvmArgs.add('-XX:+AllowEnhancedClassRedefinition')
mods {
forestry {
source sourceSets.main
}
}
}
client {}
server {
workingDirectory project.file("run/server")
}
data {
args "--mod", "gendustry", "--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 {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}
maven {
name = 'ModKit'
url 'https://jitpack.io'
content { includeGroup 'com.github.thedarkcolour' }
}
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
forRepositories(fg.repository) // Only add this if you're using ForgeGradle, otherwise remove this line
filter {
includeGroup "maven.modrinth"
}
}
}
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")
// 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:58dcc30770')
implementation fg.deobf("maven.modrinth:forestry-community-edition:$forestryVersion")
implementation fg.deobf("maven.modrinth:cofh-core:11.0.2")
implementation fg.deobf("maven.modrinth:thermal-foundation:11.0.6")
implementation fg.deobf("maven.modrinth:thermal-dynamics:11.0.1")
}
// Include resources generated by data generators.
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,
"forestryVersionRange" : forestryVersionRange,
]
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"
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}
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 = "Gendustry: Community Edition ${project.version}"
relations {
requiredDependency 'forestry-community-edition'
}
}
}
}
}
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = project.modrinthId
versionName = "Gendustry: Community Edition $version"
versionNumber = version.toString()
versionType = "release"
gameVersions = [minecraftVersion]
loaders = ["forge"]
changelog = getChangelog(project.version)
uploadFile = jar
dependencies {
required.project("forestry-community-edition")
}
}
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 "## Gendustry $version\n" + chunk.substring(lineTerminatorIndex + 1)
}
}
// Fallback in case this fails
return "Gendustry Update ${version}"
}