1
1
import net.darkhax.curseforgegradle.TaskPublishCurseForge
2
2
3
3
plugins {
4
- id ' net.neoforged.gradle' version ' [6.0.18,6.2)'
5
- id ' org.parchmentmc.librarian.forgegradle' version ' 1.+'
4
+ id ' net.neoforged.moddev' version ' 1.0.23'
6
5
7
6
id ' idea'
8
7
@@ -21,91 +20,129 @@ base {
21
20
}
22
21
23
22
java {
24
- toolchain. languageVersion = JavaLanguageVersion . of(17 )
23
+ toolchain. languageVersion = JavaLanguageVersion . of(21 )
25
24
26
25
withJavadocJar()
27
26
withSourcesJar()
28
27
}
29
28
30
- minecraft {
31
- mappings channel : mapping_channel, version : " ${ parchment_version} -${ minecraft_version} "
29
+ neoForge {
30
+ // Specify the version of NeoForge to use.
31
+ version = project. neo_version
32
32
33
- // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
33
+ parchment {
34
+ mappingsVersion = project. parchment_version
35
+ minecraftVersion = project. minecraft_version
36
+ }
34
37
35
- copyIdeResources = true
38
+ // This line is optional. Access Transformers are automatically detected
39
+ // accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg')
36
40
37
41
// Default run configurations.
38
- // These can be tweaked, removed, or duplicated as needed.
39
42
runs {
40
- // applies to all the run configs below
41
- configureEach {
42
- workingDirectory project. file(' run' )
43
-
44
- // Recommended logging data for a userdev environment
45
- // The markers can be added/remove as needed separated by commas.
46
- // "SCAN": For mods scan.
47
- // "REGISTRIES": For firing of registry events.
48
- // "REGISTRYDUMP": For getting the contents of all registries.
49
- property ' forge.logging.markers' , ' REGISTRIES'
50
-
51
- property ' forge.logging.console.level' , ' debug'
52
-
53
- mods {
54
- " ${ mod_id} " {
55
- source sourceSets. main
56
- }
57
- }
58
- }
59
-
60
43
client {
61
- property ' forge.enabledGameTestNamespaces' , mod_id
62
- property ' mixin.env.remapRefMap' , ' true'
63
- property ' mixin.env.refMapRemappingFile' , " ${ buildDir} /createSrgToMcp/output.srg"
44
+ client()
45
+
46
+ // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
47
+ systemProperty ' neoforge.enabledGameTestNamespaces' , project. mod_id
64
48
}
65
49
66
50
server {
67
- property ' forge.enabledGameTestNamespaces' , mod_id
68
- property ' mixin.env.remapRefMap' , ' true'
69
- property ' mixin.env.refMapRemappingFile' , " ${ buildDir} /createSrgToMcp/output.srg"
70
- args ' --nogui'
51
+ server()
52
+ programArgument ' --nogui'
53
+ systemProperty ' neoforge.enabledGameTestNamespaces' , project. mod_id
71
54
}
72
55
56
+ // This run config launches GameTestServer and runs all registered gametests, then exits.
57
+ // By default, the server will crash when no gametests are provided.
58
+ // The gametest system is also enabled by default for other run configs under the /test command.
73
59
gameTestServer {
74
- property ' forge.enabledGameTestNamespaces' , mod_id
60
+ type = " gameTestServer"
61
+ systemProperty ' neoforge.enabledGameTestNamespaces' , project. mod_id
75
62
}
76
63
77
- data {
78
- // example of overriding the workingDirectory set in configureEach above
79
- workingDirectory project. file(' run-data' )
64
+ clientData {
65
+ clientData()
66
+
67
+ // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
68
+ // gameDirectory = project.file('run-data')
80
69
81
70
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
82
- args ' --mod' , mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ), ' --existing' , file(' src/main/resources/' )
71
+ programArguments. addAll ' --mod' , project. mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ). getAbsolutePath(), ' --existing' , file(' src/main/resources/' ). getAbsolutePath()
72
+ }
73
+
74
+ // applies to all the run configs above
75
+ configureEach {
76
+ // Recommended logging data for a userdev environment
77
+ // The markers can be added/remove as needed separated by commas.
78
+ // "SCAN": For mods scan.
79
+ // "REGISTRIES": For firing of registry events.
80
+ // "REGISTRYDUMP": For getting the contents of all registries.
81
+ systemProperty ' forge.logging.markers' , ' REGISTRIES'
82
+
83
+ // Recommended logging level for the console
84
+ // You can set various levels here.
85
+ // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
86
+ logLevel = org.slf4j.event.Level . DEBUG
83
87
}
84
88
}
89
+
90
+ mods {
91
+ // define mod <-> source bindings
92
+ // these are used to tell the game which sources are for which mod
93
+ // mostly optional in a single mod project
94
+ // but multi mod projects should define one per mod
95
+ " ${ mod_id} " {
96
+ sourceSet(sourceSets. main)
97
+ }
98
+ }
99
+
100
+ unitTest {
101
+ // Enable JUnit support in the moddev plugin
102
+ enable()
103
+ // Configure which mod is being tested.
104
+ // This allows NeoForge to load the test/ classes and resources as belonging to the mod.
105
+ testedMod = mods. " ${ mod_id} "
106
+ }
85
107
}
86
108
87
109
// Include resources generated by data generators.
88
110
sourceSets. main. resources { srcDir ' src/generated/resources' }
89
111
112
+ // Sets up a dependency configuration called 'localRuntime'.
113
+ // This configuration should be used instead of 'runtimeOnly' to declare
114
+ // a dependency that will be present for runtime testing but that is
115
+ // "optional", meaning it will not be pulled by dependents of this mod.
116
+ configurations {
117
+ runtimeClasspath. extendsFrom localRuntime
118
+ }
119
+
90
120
/* -------------------------------------------- */
91
121
/* Dependencies */
92
122
/* -------------------------------------------- */
93
123
94
- repositories {}
124
+ repositories {
125
+ mavenLocal()
126
+ }
95
127
96
128
dependencies {
97
- minecraft " net.neoforged:forge:${ minecraft_version} -${ neo_version} "
98
-
99
129
// Testing
100
130
testImplementation " org.junit.jupiter:junit-jupiter-api:${ junit_version} "
101
131
testRuntimeOnly " org.junit.jupiter:junit-jupiter-engine:${ junit_version} "
132
+ testImplementation " net.neoforged:testframework:${ neo_version} " }
133
+
134
+ idea {
135
+ module {
136
+ downloadSources = true
137
+ downloadJavadoc = true
138
+ }
102
139
}
103
140
104
141
/* -------------------------------------------- */
105
142
/* Tasks */
106
143
/* -------------------------------------------- */
107
144
108
- tasks. named( ' processResources ' , ProcessResources ). configure {
145
+ var generateModMetadata = tasks. register( " generateModMetadata " , ProcessResources ) {
109
146
var replaceProperties = [
110
147
minecraft_version : minecraft_version, minecraft_version_range : minecraft_version_range,
111
148
neo_version : neo_version, neo_version_range : neo_version_range,
@@ -115,12 +152,17 @@ tasks.named('processResources', ProcessResources).configure {
115
152
]
116
153
117
154
inputs. properties replaceProperties
118
-
119
- filesMatching([' META-INF/mods.toml' , ' pack.mcmeta' ]) {
120
- expand replaceProperties + [project : project]
121
- }
155
+ expand replaceProperties
156
+ from " src/main/templates"
157
+ into " build/generated/sources/modMetadata"
122
158
}
123
159
160
+ // Include the output of "generateModMetadata" as an input directory for the build
161
+ // this works with both building through Gradle and the IDE.
162
+ sourceSets. main. resources. srcDir generateModMetadata
163
+ // To avoid having to run "generateModMetadata" manually, make it run on every project reload
164
+ neoForge. ideSyncTask generateModMetadata
165
+
124
166
tasks. named(' jar' , Jar ). configure {
125
167
manifest {
126
168
attributes([
@@ -133,8 +175,6 @@ tasks.named('jar', Jar).configure {
133
175
" Implementation-Timestamp" : new Date (). format(" yyyy-MM-dd'T'HH:mm:ssZ" )
134
176
])
135
177
}
136
-
137
- finalizedBy ' reobfJar'
138
178
}
139
179
140
180
tasks. register(' printVersion' ) {
0 commit comments