-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
285 lines (257 loc) · 9.92 KB
/
Copy pathbuild.gradle
File metadata and controls
285 lines (257 loc) · 9.92 KB
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
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import java.util.function.Consumer
plugins {
id('java')
id('eclipse')
id('idea')
id('maven-publish')
// https://projects.neoforged.net/neoforged/ModDevGradle
id('net.neoforged.moddev') version('2.0.78')
}
tasks.named('wrapper', Wrapper) {
//Define wrapper values here so as to not have to always do so when updating gradlew.properties
gradleVersion = '8.13'
distributionType = Wrapper.DistributionType.ALL
}
defaultTasks 'build'
idea {
module {
//Exclude directories from being managed
for (String excludeDirName in ["run", "out", "logs", "gradle"]) {
excludeDirs.add(new File(projectDir, excludeDirName))
}
}
}
sourceSets {
main {
resources {
srcDirs += 'src/datagen/generated'
//There is no need to pack the Data Generator cache into the build
exclude '.cache'
}
}
datagen {
java.srcDirs = ['src/datagen/java']
resources.srcDirs = ['src/datagen/resources']
compileClasspath += main.output
}
// These source-sets only exist for the sake of assembling a dependency graph
// for IntelliJ. Each of these will become an IntelliJ module when the project is imported,
// and will be set as the "main module" for the IntelliJ runs. A compile dependency
// on the other source sets is enough, since runtime classpath is managed by MDG anyway.
runMain {
runtimeClasspath += main.runtimeClasspath
compileClasspath += main.output
}
runData {
compileClasspath += runMain.compileClasspath + datagen.compileClasspath
runtimeClasspath += runMain.runtimeClasspath + datagen.runtimeClasspath
}
}
configurations {
//Let the datagen source set know about forge
datagenImplementation.extendsFrom(implementation)
datagenCompileOnly.extendsFrom(compileOnly)
datagenRuntimeOnly.extendsFrom(runtimeOnly)
sourceSets.main.runtimeClasspath += localRuntime
}
def replaceResources = tasks.register("replaceResources", Copy) {
def versionProperties = ["version" : mod_version, "mc_version": minecraft_version_range, "neo_version": neo_version_range,
"loader_version": loader_version_range, "projecte_version": projecte_version_range]
inputs.properties(versionProperties)
def modsToml = copySpec {
from(sourceSets.main.resources) {
include "META-INF/neoforge.mods.toml"
expand versionProperties
}
}
//Copy it into the build dir
it.with modsToml
it.into layout.buildDirectory.dir('resources/main/')
//If IntelliJ's output dir exists, copy it there as well
if (new File("$rootDir/out/production/").exists()) {
copy {
with modsToml
into "$rootDir/out/production/"
}
}
//If Eclipse's output dir exists, copy it there as well
if (new File("$rootDir/bin/main/").exists()) {
copy {
with modsToml
into "$rootDir/bin/main/"
}
}
}
group = 'dev.freimer.projectextended'
version = "${mod_version}"
project.base.archivesName = 'ProjectExtended'
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
vendor.set(JvmVendorSpec.JETBRAINS)
}
}
neoForge {
version = neo_version
addModdingDependenciesTo(sourceSets.datagen)
accessTransformers.from(
file('src/main/resources/META-INF/accesstransformer.cfg'),
//Dev time only ATs so the file name doesn't have to match accesstransformer.cfg
//file('src/datagen/resources/META-INF/datagen_ats.cfg')
)
mods {
projectextended {
sourceSet(sourceSets.main)
}
projectextended_datagen {
sourceSet(sourceSets.main)
sourceSet(sourceSets.datagen)
}
}
}
neoForge.runs {
configureEach {
if (project.hasProperty('forge_force_ansi')) {
//Force ansi if declared as a gradle variable, as the auto detection doesn't detect IntelliJ properly
// or eclipse's plugin that adds support for ansi escape in console
systemProperties.put('terminal.ansi', (String) property('forge_force_ansi'))
}
systemProperties.put('projecte.skip_top', "true")
//if the selected toolchain is a JBR, enable DCEVM
if (javaToolchains.launcherFor(java.toolchain).map { it.metadata.vendor }.getOrElse('').contains('JetBrains')) {
jvmArguments.addAll('-XX:+IgnoreUnrecognizedVMOptions', '-XX:+AllowEnhancedClassRedefinition')
}
sourceSet = sourceSets.runMain
}
client {
client()
//Note: To enable logging into the client account, set the mc_devlogin property to true in your gradle user home
if (findProperty('mc_devlogin') ?: false) {
//If the property is present and set to true, enable dev login
devLogin = true
}
}
clientAlt {
client()
// Force a different username in case devlogin is not enabled for the main run
programArguments.addAll((String[]) ['--username', 'AltDev'])
}
server {
server()
programArgument('--nogui')
}
data {
data()
programArguments.addAll('--all', '--output', project.file('src/datagen/generated/').getAbsolutePath(),
'--mod', 'projectextended', '--existing', project.file('src/main/resources/').getAbsolutePath(),
'--existing-mod', 'projecte')
sourceSet = sourceSets.runData
loadedMods = [neoForge.mods.projectextended_datagen]
}
}
static void exclusiveRepo(RepositoryHandler handler, String url, String... groups) {
exclusiveRepo(handler, url, filter -> {
for (def group : groups) {
filter.includeGroup(group)
}
})
}
static void exclusiveRepo(RepositoryHandler handler, String url, Consumer<InclusiveRepositoryContentDescriptor> filterSetup) {
handler.exclusiveContent {
it.forRepositories(handler.maven {
setUrl(url)
})
it.filter { f -> filterSetup.accept(f) }
}
}
repositories { RepositoryHandler handler ->
exclusiveRepo(handler, 'https://maven.blamejared.com', filter -> {
filter.includeGroupAndSubgroups('com.blamejared')
filter.includeGroupAndSubgroups('net.darkhax')
filter.includeGroup('org.openzen.zencode')
filter.includeGroup('mezz.jei')
})
exclusiveRepo(handler, 'https://www.cursemaven.com', 'curse.maven')
exclusiveRepo(handler, 'https://maven.thiakil.com', 'moze_intel.projecte')
exclusiveRepo(handler, 'https://maven.parchmentmc.org/', 'org.parchmentmc.data')
flatDir {
dirs "libs"
}
}
dependencies {
if (project.hasProperty('projecte_local_version')) {
implementation("projecte:projecte:${projecte_local_version}")
} else if (project.hasProperty('projecte_version')) {
implementation("moze_intel.projecte:ProjectE:${projecte_version}")
} else {
implementation("curse.maven:projecte-226410:${projecte_fileid}")
}
//Include JEI in the dev environment
localRuntime("mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}")
localRuntime("net.darkhax.bookshelf:bookshelf-neoforge-${minecraft_version}:${bookshelf_version}")
def gameStages = "net.darkhax.gamestages:GameStages-Forge-${previous_minor_minecraft_version}:${gamestages_version}"
compileOnly(gameStages)
//localRuntime(gameStages)
}
//Set the various variables/settings for the different process resources tasks
tasks.named('processResources', ProcessResources) {
duplicatesStrategy = DuplicatesStrategy.FAIL
exclude('META-INF/neoforge.mods.toml')
finalizedBy(replaceResources)
from("${projectDir}") { include('logo.png') }
def files = fileTree(dir: outputs.files.asPath, includes: ['**/*.json', '**/*.mcmeta'])
doLast {
for (def file : files) {
file.text = JsonOutput.toJson(new JsonSlurper().parse(file))
}
}
}
//Make the various classes tasks depend on the corresponding replaceResources tasks in addition to the default processResources tasks they depend on
tasks.named('classes') { dependsOn(replaceResources) }
tasks.named('jar', Jar) {
duplicatesStrategy = DuplicatesStrategy.FAIL
manifest.attributes([
"Specification-Title" : "ProjectExtended",
"Specification-Vendor" : "pupnewfster",
"Specification-Version" : "${mod_version}",
"Implementation-Title" : "ProjectExtended",
"Implementation-Version" : "${mod_version}",
"Implementation-Vendor" : "pupnewfster",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"Automatic-Module-Name" : "projectextended"
])
}
tasks.withType(JavaCompile).configureEach({
it.options.encoding = 'UTF-8'
it.options.compilerArgs << "-Xmaxerrs" << "100000"
})
publishing {
publications { PublicationContainer publicationContainer ->
publicationContainer.register('maven', MavenPublication) { MavenPublication publication ->
publication.from((SoftwareComponent) components.java)
publication.groupId = project.group
publication.version = project.version
publication.artifactId = 'ProjectExtended'
publication.artifacts = [jar]
publication.pom {
name.set('ProjectExtended')
packaging = 'jar'
scm {
url.set('https://github.com/pupnewfster/ProjectExtended.git')
}
issueManagement {
system.set('github')
url.set('https://github.com/pupnewfster/ProjectExtended/issues')
}
licenses {
license {
name.set('MIT')
distribution.set('repo')
}
}
}
}
}
}