-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
190 lines (156 loc) · 6.41 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
plugins {
id "eclipse"
id "idea"
id "java-library"
id "net.minecraftforge.gradle" version "6.0.25"
id "org.spongepowered.mixin" version "0.7.+"
id "me.modmuss50.mod-publish-plugin" version "0.5.2"
}
version = mod_version + "-forge-" + minecraft_suffix
group = maven_group
base.archivesName = mod_id
java.toolchain.languageVersion = JavaLanguageVersion.of(java_target)
println("Java: " + System.getProperty("java.version") + " JVM: " + System.getProperty("java.vm.version") + "(" + System.getProperty("java.vendor") + ") Arch: " + System.getProperty("os.arch"))
// Keep parameter names when compiling
compileJava.options.compilerArgs.add '-parameters'
repositories {
flatDir { dirs "libs" }
maven { url "https://www.cursemaven.com" }
exclusiveContent {
forRepository {
maven { url = "https://api.modrinth.com/maven" }
}
filter { includeGroup "maven.modrinth" }
}
maven { url = "https://repo.spongepowered.org/maven" }
}
dependencies {
// Forge
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
// Core library
implementation fg.deobf("curse.maven:supermartijn642s-core-lib-454372:${core_library_file}")
// Config library
implementation fg.deobf("curse.maven:supermartijn642s-config-lib-438332:${config_library_file}")
// Just Enough Items
runtimeOnly fg.deobf("curse.maven:jei-238222:${just_enough_items_file}")
// Block Renderer
runtimeOnly fg.deobf("curse.maven:block-renderer-380456:${block_renderer_file}")
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir "src/generated/resources" }
processResources {
inputs.property "version", version
// Replace the mod version
Map<String, ?> copyProperties = project.properties.clone() as Map<String, ?>
//noinspection UnnecessaryQualifiedReference
var matcher = java.util.regex.Pattern.compile("[^.0-9]").matcher(copyProperties.mod_version as String)
if (matcher.find())
copyProperties.mod_version = copyProperties.mod_version.substring(0, matcher.start()) + "+" + copyProperties.mod_version.substring(matcher.start())
filesMatching(["META-INF/mods.toml", "modid.mixins.json", "pack.mcmeta"]) {
expand copyProperties
}
exclude "**/*.pdn"
rename "^modid.mixins.json\$", "${mod_id}.mixins.json"
rename "^icon.png\$", "${mod_id}.png"
}
minecraft {
mappings channel: "official", version: minecraft_version
// accessTransformer = file("src/main/resources/META-INF/accesstransformer.cfg")
runs {
configureEach {
workingDirectory file("run")
property "forge.logging.markers", "REGISTRIES"
mods {
//noinspection GroovyAssignabilityCheck
source sourceSets.main
}
}
client {
}
server {
}
data {
args "--mod", mod_id
args "--all"
args "--output", file("src/generated/resources/")
args "--existing", layout.buildDirectory.file("/data_resources").map { it.asFile }.get()
}
}
}
// Rename the IntelliJ run configs
gradle.taskGraph.whenReady {
tasks.genIntellijRuns.doLast {
def configDir = it.getRunConfigurationsFolder().get().getAsFile()
minecraft.runs.each {
//noinspection GroovyAssignabilityCheck
def configFile = new File(configDir, it.getUniqueFileName() + ".xml")
if(configFile.exists()){
def xml = new groovy.xml.XmlSlurper().parse(configFile)
//noinspection GrUnresolvedAccess
xml.configuration.@name = "Forge " + it.name.capitalize()
configFile.withWriter { groovy.xml.XmlUtil.serialize(xml, it) }
}
}
}
}
tasks.register('prepareDataResources', Sync) {
from file("src/main/resources")
into layout.buildDirectory.dir("/data_resources")
inputs.property "version", version
// Replace the mod version
Map<String, ?> copyProperties = project.properties.clone() as Map<String, ?>
//noinspection UnnecessaryQualifiedReference
var matcher = java.util.regex.Pattern.compile("[^.0-9]").matcher(copyProperties.mod_version as String)
if (matcher.find())
copyProperties.mod_version = copyProperties.mod_version.substring(0, matcher.start()) + "+" + copyProperties.mod_version.substring(matcher.start())
filesMatching(["META-INF/mods.toml", "modid.mixins.json", "pack.mcmeta"]) {
expand copyProperties
}
exclude "**/*.pdn"
rename "^modid.mixins.json\$", "${mod_id}.mixins.json"
rename "^icon.png\$", "${mod_id}.png"
}
// Run prepareDataResources before prepareRunData
tasks.configureEach {
if (it.name == "prepareRunData" || it.name == "prepareRunDataCompile")
it.dependsOn "prepareDataResources"
}
// Force the jar to be reobfuscated
jar.finalizedBy('reobfJar')
publishMods {
file = jar.archiveFile
displayName = "${mod_name} ${mod_version} for Forge ${minecraft_suffix.substring(2)}"
version = project.version
//noinspection UnnecessaryQualifiedReference
type = me.modmuss50.mpp.ReleaseType.of(publishing_release_type.toUpperCase())
changelog = file("changelog.md").text
modLoaders.add("forge")
maxRetries = 2
curseforge {
accessToken = System.getenv("CURSEFORGE_TOKEN")
projectId = curseforge_project_id
if (!curseforge_required_dependency_ids.isEmpty())
curseforge_required_dependency_ids.split(" ").each it::requires
if (!curseforge_optional_dependency_ids.isEmpty())
curseforge_optional_dependency_ids.split(" ").each it::optional
publishing_game_versions.split(" ").each minecraftVersions::add
clientRequired = true
serverRequired = true
}
modrinth {
accessToken = System.getenv("MODRINTH_TOKEN")
projectId = modrinth_project_id
displayName = "${mod_name} ${mod_version}"
if (!modrinth_required_dependency_ids.isEmpty())
modrinth_required_dependency_ids.split(" ").each it::requires
if (!modrinth_optional_dependency_ids.isEmpty())
modrinth_optional_dependency_ids.split(" ").each it::optional
publishing_game_versions.split(" ").each minecraftVersions::add
}
}
// Rename the 'publishMods' task
tasks.publishMods.group = "other"
tasks.register("publishAll") {
group = "publishing"
dependsOn(tasks.publishMods)
}