forked from Potion-Studios/BYG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
221 lines (185 loc) · 8.19 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
import net.darkhax.curseforgegradle.TaskPublishCurseForge
import java.util.stream.Collectors
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
maven { url "https://plugins.gradle.org/m2/" }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
classpath 'org.parchmentmc:librarian:1.+'
classpath group: 'gradle.plugin.com.modrinth.minotaur', name: 'Minotaur', version: '1.2.1'
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id "net.darkhax.curseforgegradle" version "1.0.7"
}
apply plugin: 'java'
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'
tasks.build.dependsOn(tasks.findByName("shadowJar"))
configurations {
shadow
implementation.extendsFrom shadow
library
implementation.extendsFrom library
dataImplementation.extendsFrom implementation
dataCompileOnly.extendsFrom compileOnly
}
sourceSets {
data
}
minecraft.runs.all {
lazyToken('minecraft_classpath') {
configurations.library.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator)
}
}
archivesBaseName = "${mod_name}-forge-${minecraft_version}"
shadowJar {
configurations = [project.configurations.shadow]
relocate 'blue.endless.jankson', "${project.group}.shadow.blue.endless.jankson"
archiveClassifier.set('')
}
reobf {
shadowJar {
}
}
minecraft {
mappings channel: 'parchment', version: "1.18.2-${parchment_version}-1.19"
if (project.hasProperty('forge_ats_enabled') && project.findProperty('forge_ats_enabled').toBoolean()) {
// This location is hardcoded in Forge and can not be changed.
// https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
project.logger.debug('Forge Access Transformers are enabled for this project.')
}
runs {
def runArgs = ["-DbygDev=true"]
client {
jvmArgs runArgs
workingDirectory project.file('run')
args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}_forge.mixins.json"
ideaModule "${rootProject.name}.${project.name}.main"
taskName 'Client'
def output = sourceSets.main.output;
def commonOutput = project(":Common").sourceSets.main.output;
environment("MOD_CLASSES", [output.classesDirs.asPath, output.resourcesDir.path, commonOutput.classesDirs.asPath, commonOutput.resourcesDir.path].join(";"))
mods {
modClientRun {
source sourceSets.main
source project(":Common").sourceSets.main
}
}
}
server {
jvmArgs runArgs
workingDirectory project.file('run')
args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}_forge.mixins.json"
ideaModule "${rootProject.name}.${project.name}.main"
taskName 'Server'
def output = sourceSets.main.output;
def commonOutput = project(":Common").sourceSets.main.output;
environment("MOD_CLASSES", [output.classesDirs.asPath, output.resourcesDir.path, commonOutput.classesDirs.asPath, commonOutput.resourcesDir.path].join(";"))
mods {
modServerRun {
source sourceSets.main
source project(":Common").sourceSets.main
}
}
}
data {
jvmArgs runArgs
workingDirectory project.file('run')
ideaModule "${rootProject.name}.${project.name}.main"
args '--mod', mod_id, '--all', '--output', project(':Common').file('src/generated/resources'), '--existing', project(':Common').file('src/main/resources'), "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}_forge.mixins.json"
taskName 'Data'
def output = sourceSets.main.output;
def commonOutput = project(":Common").sourceSets.main.output;
environment("MOD_CLASSES", [output.classesDirs.asPath, sourceSets.data.output.asPath, output.resourcesDir.path, commonOutput.classesDirs.asPath, commonOutput.resourcesDir.path].join(";"))
mods {
byg {
source sourceSets.main as SourceSet
source sourceSets.data as SourceSet
source project(":Common").sourceSets.main as SourceSet
}
}
}
}
}
dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
compileOnly project(":Common")
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
implementation fg.deobf("com.github.glitchfiend:TerraBlender-forge:${minecraft_version}-${terrablender_version}")
library shadow("blue.endless:jankson:${jankson_version}")
dataImplementation sourceSets.main.output
}
reg.configureJarTask(shadowJar)
mixin {
add project(":Common").sourceSets.main, "${mod_id}.refmap.json"
add sourceSets.main, "${mod_id}_forge.refmap.json"
config "${mod_id}.mixins.json"
config "${mod_id}_forge.mixins.json"
}
tasks.withType(JavaCompile) {
source(project(":Common").sourceSets.main.allSource)
}
processResources {
from project(":Common").sourceSets.main.resources
filesMatching("${mod_id}.mixins.json") {
expand "refmap_target": "${mod_id}."
}
}
jar.finalizedBy('reobfJar')
jar {
archiveClassifier.set('slim')
}
task forge_checkForRefmap() {
doLast {
File file1 = shadowJar.archiveFile.get().asFile
logger.info("Verifying refmap exists...")
if (file1.exists()) {
FileTree files = zipTree(file1)
Set<String> fileNames = files.getFiles().stream().map(file -> file.getName()).collect(Collectors.toSet())
String forgeRefmap = "${mod_id}_forge.refmap.json"
String commonRefmap = "${mod_id}.refmap.json"
if (!fileNames.contains(forgeRefmap) || !fileNames.contains(commonRefmap)) {
throw new IllegalStateException("Refmap is missing.")
}
} else {
throw new IllegalStateException("File is missing.")
}
logger.info("Refmap found!")
}
}
task forge_publishCurseForge(type: TaskPublishCurseForge) {
apiToken = "$System.env.CURSEFORGE_KEY"
int projectId = 247560
String changelogText = projectDir.toPath().getParent().resolve("CHANGELOG.md").getText('UTF-8')
def mainFile = upload(projectId, shadowJar)
mainFile.changelog = changelogText
mainFile.changelogType = "markdown"
mainFile.releaseType = "${project.release_type}"
mainFile.addRequirement("terrablender")
mainFile.addGameVersion("${project.minecraft_version}")
mainFile.addModLoader("forge")
}
task forge_buildAndReleaseCurseforge {}
tasks.forge_checkForRefmap.mustRunAfter tasks.build
tasks.forge_publishCurseForge.mustRunAfter tasks.forge_checkForRefmap
tasks.forge_buildAndReleaseCurseforge.dependsOn(tasks.build, tasks.forge_checkForRefmap, tasks.forge_publishCurseForge)
apply from: 'gradle/modrinth.gradle'
task forge_buildAndReleaseModrinth {}
tasks.forge_checkForRefmap.mustRunAfter tasks.build
tasks.forge_publishModrinth.mustRunAfter tasks.forge_checkForRefmap
tasks.forge_buildAndReleaseModrinth.dependsOn(tasks.build, tasks.forge_checkForRefmap, tasks.forge_publishModrinth)
task forge_buildAndReleaseModrinthAndCurseforge {}
tasks.forge_checkForRefmap.mustRunAfter tasks.build
tasks.forge_publishCurseForge.mustRunAfter tasks.forge_checkForRefmap
tasks.forge_publishModrinth.mustRunAfter tasks.forge_publishCurseForge
tasks.forge_buildAndReleaseModrinthAndCurseforge.dependsOn(tasks.build, tasks.forge_checkForRefmap, tasks.forge_publishCurseForge, tasks.forge_publishModrinth)