-
Notifications
You must be signed in to change notification settings - Fork 27
/
build.gradle
267 lines (232 loc) · 7.74 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
import com.diffplug.spotless.FormatterFunc
import com.diffplug.spotless.FormatterStep
import com.google.gson.Gson
import com.google.gson.GsonBuilder
plugins {
id "java-library"
id "net.neoforged.moddev"
id "me.shedaniel.unified-publishing"
id "com.diffplug.spotless"
id "maven-publish"
}
repositories {
maven {
url = "https://maven.theillusivec4.top"
content {
includeGroup "top.theillusivec4.curios"
}
}
maven {
name = "blamejared"
url = "https://maven.blamejared.com/"
content {
includeGroup "mezz.jei"
}
}
maven {
name 'modmaven'
url "https://modmaven.dev/"
content {
includeGroup "mezz.jei"
}
}
maven {
url "https://maven.shedaniel.me"
content {
includeGroup "me.shedaniel"
includeGroup "me.shedaniel.cloth"
includeGroup "dev.architectury"
}
}
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/releases/"
content {
includeGroup "dev.emi"
}
}
}
apply plugin: "me.shedaniel.unified-publishing"
dependencies {
implementation "me.shedaniel.cloth:cloth-config-neoforge:${project.cloth_config_version}"
// compile against provided APIs
compileOnly "dev.emi:emi-neoforge:${emi_version}:api"
compileOnly "mezz.jei:jei-${project.jei_minecraft_version}-neoforge-api:${project.jei_version}"
if (project.runtime_itemlist_mod != "rei") {
compileOnly "me.shedaniel:RoughlyEnoughItems-neoforge:${project.rei_version}"
}
if (project.runtime_itemlist_mod == "emi") {
runtimeOnly "dev.emi:emi-neoforge:${emi_version}"
} else if (project.runtime_itemlist_mod == "rei") {
implementation "me.shedaniel:RoughlyEnoughItems-neoforge:${project.rei_version}"
} else if (project.runtime_itemlist_mod == "jei") {
runtimeOnly "mezz.jei:jei-${project.jei_minecraft_version}-neoforge:${project.jei_version}"
} else if (project.runtime_itemlist_mod == "none") {
// none
} else {
throw new GradleException("Unknown setting for project.runtime_itemlist_mod=${project.runtime_itemlist_mod}. Supported: emi, rei, jei and none")
}
compileOnly "top.theillusivec4.curios:curios-neoforge:${project.curios_version}:api"
}
base {
archivesName = project.archives_base_name
}
version = (System.getenv("POWAH_VERSION") ?: "v0.0.0").substring(1)
group = project.maven_group
java {
withSourcesJar()
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
}
}
sourceSets {
main {
resources {
srcDir "src/generated/resources"
}
}
}
processResources {
inputs.property "version", project.version
filesMatching("META-INF/neoforge.mods.toml") {
filter { line ->
line.replace 'version="0.0.0"', "version=\"$version\""
}
}
}
neoForge {
version = project.neoforge_version
mods {
powah {
modSourceSets = [sourceSets.main]
}
}
runs {
client {
client()
}
server {
server()
}
data {
data()
programArguments = ['--mod', 'powah',
'--all',
'--output', file('src/generated/resources/').absolutePath,
'--existing', file('src/main/resources').absolutePath]
}
}
}
publishing {
publications {
maven(MavenPublication) {
artifactId = rootProject.archives_base_name
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.
}
}
if (project.version != "0.0.0") {
def loader = "neoforge"
unifiedPublishing {
project {
gameVersions = [project.minecraft_version]
gameLoaders = [loader]
version = project.version + "-" + loader
def releaseChannel = "release"
def changes = System.getenv("CHANGELOG") ?: "No changelog provided?"
if (project.version.toLowerCase().contains("alpha")) {
releaseChannel = "alpha"
changes = "THIS IS AN ALPHA RELEASE, MAKE A BACKUP BEFORE INSTALLING AND FREQUENTLY WHILE PLAYING, AND PLEASE REPORT ANY ISSUE YOU MAY FIND ON THE ISSUE TRACKER.\n\n" + changes
} else if (project.version.toLowerCase().contains("beta")) {
releaseChannel = "beta"
changes = "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" + changes
}
releaseType = releaseChannel
changelog = changes
displayName = String.format("[%s %s] v%s", loader.toUpperCase(), project.minecraft_version, project.version)
mainPublication jar // Declares the publicated jar
relations {
depends {
curseforge = "cloth-config"
modrinth = "cloth-config"
}
}
var cfToken = System.getenv("CF_TOKEN")
if (cfToken != null) {
curseforge {
token = cfToken
id = "633483" // Required, must be a string, ID of CurseForge project
if (project.name == "fabric" && releaseChannel == "release") {
// Use beta channel for Fabric releases on CurseForge, to separate from Forge builds
releaseType = "beta"
}
}
}
var mrToken = System.getenv("MODRINTH_TOKEN")
if (mrToken != null) {
modrinth {
token = mrToken
id = "KZO4S4DO" // Required, must be a string, ID of Modrinth project
}
}
}
}
}
spotless {
format 'misc', {
target '*.gradle', '*.md', '.gitignore'
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
java {
target '**/*.java'
importOrder()
removeUnusedImports()
eclipse().configFile('eclipse-format.xml')
indentWithSpaces()
endWithNewline()
// TODO: Enforce license header one day
//licenseHeaderFile 'license_header.java'
}
format 'json', {
target '**/lang/*.json'
addStep(JsonOrderStep.create())
}
}
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;
}
}