-
Notifications
You must be signed in to change notification settings - Fork 14
/
build.gradle
290 lines (256 loc) · 8.3 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
plugins {
id 'net.neoforged.moddev'
id 'maven-publish'
id 'com.diffplug.spotless'
id 'com.matthewprenger.cursegradle'
id "com.modrinth.minotaur"
}
def archivesBaseName = project.archives_base_name
version = System.getenv("MOD_VERSION")
? System.getenv("MOD_VERSION")
: "0.0.0"
group = project.maven_group
repositories {
maven {
url "https://maven.shedaniel.me"
content {
includeGroup "me.sargunvohra.mcmods"
includeGroup "me.shedaniel.cloth"
includeGroup "me.shedaniel"
includeGroup "dev.architectury"
}
}
maven {
url "https://maven.terraformersmc.com"
content {
includeGroup "com.terraformersmc"
includeGroup "dev.emi"
}
}
maven {
url 'https://maven.bai.lol'
content {
includeGroup "lol.bai"
includeGroup "mcp.mobius.waila"
}
}
maven {
name 'modmaven'
url "https://modmaven.dev/"
content {
includeGroup "mezz.jei"
}
}
maven {
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}
}
dependencies {
if (project.runtime_itemlist_mod == "jei") {
implementation("mezz.jei:jei-${project.jei_minecraft_version}-neoforge:${project.jei_version}") {
exclude group: "mezz.jei"
}
} else {
compileOnly("mezz.jei:jei-${project.jei_minecraft_version}-neoforge:${project.jei_version}") {
exclude group: "mezz.jei"
}
}
if (project.runtime_itemlist_mod == "rei") {
implementation("me.shedaniel:RoughlyEnoughItems-neoforge:${project.rei_version}")
} else {
compileOnly("me.shedaniel:RoughlyEnoughItems-neoforge:${project.rei_version}")
}
if (project.runtime_itemlist_mod == "emi") {
implementation("dev.emi:emi-neoforge:${project.emi_version}+${project.emi_minecraft_version}")
// Add JEI at runtime to activate EMI's builtin JEI compat
runtimeOnly("mezz.jei:jei-${project.jei_minecraft_version}-neoforge:${project.jei_version}") {
exclude group: "mezz.jei"
}
} else {
compileOnly("dev.emi:emi-neoforge:${project.emi_version}+${project.emi_minecraft_version}")
}
if (!(project.runtime_itemlist_mod in ["jei", "rei", "emi"])) {
throw new GradleException("Invalid runtime_itemlist_mod value: " + project.runtime_itemlist_mod)
}
implementation("curse.maven:jade-324717:${project.jade_file_id}")
}
processResources {
def version = project.version
inputs.property "version", version
filesMatching("META-INF/neoforge.mods.toml") {
expand "version": version
}
}
sourceSets {
main {
resources {
srcDir "src/generated/resources"
}
}
}
neoForge {
version = project.neoforge_version
mods {
moderndynamics {
sourceSet sourceSets.main
}
}
runs {
client {
client()
}
gametestWorld {
client()
programArguments.addAll("--username", "MDDev", "--quickPlaySingleplayer", "GametestWorld")
}
server {
server()
}
data {
data()
programArguments = [
'--mod', 'moderndynamics',
'--all',
'--output', file('src/generated/resources/').absolutePath,
'--existing', file('src/main/resources').absolutePath
]
}
// Use to run the tests
gametest {
type = "gameTestServer"
gameDirectory = project.file("build/gametest")
}
}
}
test.dependsOn runGametest
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.deprecation = false
options.compilerArgs << "-Xmaxerrs" << "9999"
}
jar {
from("LICENSE") {
rename { "${it}_${archivesBaseName}"}
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
spotless {
format 'misc', {
target '*.gradle', '*.md', '.gitignore'
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
java {
importOrder()
removeUnusedImports()
eclipse().configFile('eclipse-format.xml')
indentWithSpaces()
endWithNewline()
licenseHeaderFile 'license_header.java'
}
format 'json', {
target 'src/**/lang/*.json'
addStep(JsonOrderStep.create())
}
}
import com.diffplug.spotless.FormatterFunc
import com.diffplug.spotless.FormatterStep
import com.google.gson.Gson
import com.google.gson.GsonBuilder
final class JsonOrderStep {
private JsonOrderStep() {}
private static final Gson GSON = new GsonBuilder().disableHtmlEscaping().setLenient().setPrettyPrinting().create();
static FormatterStep create() {
return FormatterStep.create(
'jsonOrderStep',
new State(),
{
new FormatterFunc() {
String apply(String input) {
TreeMap<String, Object> jsonMap = GSON.fromJson(input, TreeMap.class);
String sortedJson = GSON.toJson(jsonMap);
String prettyPrinted = sortedJson.replace(' "', ' "').replace('\\u0027', '\'');
return prettyPrinted;
}
}
},
);
}
private static final class State implements Serializable {
private static final long serialVersionUID = 1L;
private final int formatVersion = 1;
}
}
def releaseChannel = "release"
def changelog = "Please visit our github repository for a changelog: https://github.com/Technici4n/Modern-Dynamics/releases."
if (version.toLowerCase().contains("alpha")) {
releaseChannel = "alpha"
changelog = "THIS IS AN ALPHA RELEASE, MAKE A BACKUP BEFORE INSTALLING AND FREQUENTLY WHILE PLAYING, AND PLEASE REPORT ANY ISSUE YOU MAY FIND ON OUR ISSUE TRACKER.\n\n" + changelog
} else if (version.toLowerCase().contains("beta")) {
releaseChannel = "beta"
changelog = "This is a beta release. It is expected to be mostly stable, but in any case please report any issue you may find.\n\n" + changelog
}
// Publishing
if (System.getenv("CURSEFORGE_API_KEY") && !version.endsWith("-SNAPSHOT")) {
curseforge {
apiKey = System.getenv().get("CURSEFORGE_API_KEY")
project {
id = project.curseforge_project
releaseType = releaseChannel
changelogType = "markdown"
delegate.changelog = changelog
addGameVersion "1.21.1"
addGameVersion "NeoForge"
addGameVersion "Java 21"
mainArtifact(jar.archiveFile) {
displayName = "Modern Dynamics v${version}"
}
}
options {
forgeGradleIntegration = false
}
afterEvaluate {
tasks.getByName("curseforge${project.curseforge_project}").dependsOn jar
}
}
}
if (System.getenv("MODRINTH_API_KEY") && !version.endsWith("-SNAPSHOT")) {
modrinth {
token = System.getenv("MODRINTH_API_KEY")
projectId = project.modrinth_project
versionNumber = version
versionName = "Modern Dynamics v${version}"
delegate.changelog = changelog
versionType = releaseChannel.toUpperCase()
uploadFile = jar.archiveFile
gameVersions = ["1.21.1"]
loaders = ["neoforge"]
}
}