1- buildscript {
2- repositories {
3- maven { url = ' https://repo.spongepowered.org/repository/maven-public' }
4- }
5- dependencies {
6- classpath " org.spongepowered:mixingradle:${ mixingradle_version} "
7- }
8- }
91plugins {
102 id ' idea'
113 id ' maven-publish'
12- id ' net.minecraftforge.gradle' version ' 6.+'
13- id ' org.spongepowered.mixin' version ' 0.7.+'
4+ id ' java-library'
5+ id ' org.jreleaser' version ' 1.17.0'
6+ id ' net.neoforged.moddev' version ' 2.0.78'
7+
148}
159
10+
11+ import org.slf4j.event.Level
12+
1613import java.nio.file.Files
1714import java.nio.file.Paths
1815
@@ -38,66 +35,95 @@ base {
3835}
3936
4037// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
41- java. toolchain. languageVersion = JavaLanguageVersion . of(17 )
38+ java. toolchain. languageVersion = JavaLanguageVersion . of(21 )
4239
4340println " Java: ${ System.getProperty 'java.version'} , JVM: ${ System.getProperty 'java.vm.version'} (${ System.getProperty 'java.vendor'} ), Arch: ${ System.getProperty 'os.arch'} "
44- minecraft {
41+ // Specify the version of NeoForge to use.
42+ neoForge {
4543
46- mappings channel : mapping_channel, version : minecraft_version
44+ version = project . neo_version
4745
48- copyIdeResources = true
46+ parchment {
47+ mappingsVersion = project. parchment_mappings_version
48+ minecraftVersion = project. parchment_minecraft_version
49+ }
50+ configurations {
51+ runtimeClasspath. extendsFrom localRuntime
52+ }
4953
50- accessTransformer = file(' src/main/resources/META-INF/accesstransformers.cfg' )
54+ // This line is optional. Access Transformers are automatically detected
55+ // accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg')
5156
57+ // Default run configurations.
58+ // These can be tweaked, removed, or duplicated as needed.
5259 runs {
53- // applies to all the run configs below
54- configureEach {
55- workingDirectory project. file(' run' )
56- arg ' -mixin.config=formicapi.mixins.json'
57-
58- property ' forge.logging.markers' , ' REGISTRIES'
59-
60- // property 'forge.logging.console.level', 'debug'
61-
62- property ' mixin.env.remapRefMap' , ' true'
63- property ' mixin.env.refMapRemappingFile' , " ${ projectDir} /build/createSrgToMcp/output.srg"
64- mods {
65- " ${ mod_id} " {
66- source sourceSets. main
67- }
68- }
69- }
70-
7160 client {
61+ client()
62+
7263 // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
73- property ' forge .enabledGameTestNamespaces' , mod_id
64+ systemProperty ' neoforge .enabledGameTestNamespaces' , project . mod_id
7465 }
7566
7667 server {
77- property ' forge.enabledGameTestNamespaces' , mod_id
78- args ' --nogui'
68+ server()
69+ programArgument ' --nogui'
70+ systemProperty ' neoforge.enabledGameTestNamespaces' , project. mod_id
7971 }
8072
81-
73+ // This run config launches GameTestServer and runs all registered gametests, then exits.
74+ // By default, the server will crash when no gametests are provided.
75+ // The gametest system is also enabled by default for other run configs under the /test command.
8276 gameTestServer {
83- property ' forge.enabledGameTestNamespaces' , mod_id
77+ type = " gameTestServer"
78+ systemProperty ' neoforge.enabledGameTestNamespaces' , project. mod_id
8479 }
80+
8581 data {
86- // example of overriding the workingDirectory set in configureEach above
87- workingDirectory project. file(' run-data' )
82+ data()
83+
84+ // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
85+ // gameDirectory = project.file('run-data')
8886
8987 // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
90- args ' --mod' , mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ), ' --existing' , file(' src/main/resources/' )
88+ programArguments. addAll ' --mod' , project. mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ). getAbsolutePath(), ' --existing' , file(' src/main/resources/' ). getAbsolutePath()
89+ }
90+
91+ // applies to all the run configs above
92+ configureEach {
93+ // Recommended logging data for a userdev environment
94+ // The markers can be added/remove as needed separated by commas.
95+ // "SCAN": For mods scan.
96+ // "REGISTRIES": For firing of registry events.
97+ // "REGISTRYDUMP": For getting the contents of all registries.
98+ systemProperty ' forge.logging.markers' , ' REGISTRIES'
99+
100+ // Recommended logging level for the console
101+ // You can set various levels here.
102+ // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
103+ logLevel = Level . WARN
104+
105+
106+ }
107+ }
108+ mods {
109+ // define mod <-> source bindings
110+ // these are used to tell the game which sources are for which mod
111+ // mostly optional in a single mod project
112+ // but multi mod projects should define one per mod
113+ " ${ mod_id} " {
114+ sourceSet(sourceSets. main)
91115 }
92116 }
93117}
94118
119+
120+
95121// Include resources generated by data generators.
96122sourceSets. main. resources { srcDir ' src/generated/resources' }
97123
98124repositories {
99125 maven { url = " https://maven.createmod.net" } // Create, Ponder, Flywheel
100- maven { url = " https://maven.tterrag.com " } // Registrate
126+ maven { url = " https://mvn.devos.one/snapshots " } // Registrate
101127
102128 // JEI
103129
@@ -129,29 +155,17 @@ repositories {
129155}
130156
131157dependencies {
132- minecraft " net.minecraftforge:forge:${ minecraft_version} -${ forge_version} "
133- // TODO make sure we only depend on catnip
134- implementation(fg. deobf(" com.simibubi.create:create-${ minecraft_version} :${ create_version} :slim" ) { transitive = false })
135- implementation(fg. deobf(" net.createmod.ponder:Ponder-Forge-${ minecraft_version} :${ ponder_version} " ))
136- compileOnly(fg. deobf(" dev.engine-room.flywheel:flywheel-forge-api-${ minecraft_version} :${ flywheel_version} " ))
137- runtimeOnly(fg. deobf(" dev.engine-room.flywheel:flywheel-forge-${ minecraft_version} :${ flywheel_version} " ))
138- implementation(fg. deobf(" com.tterrag.registrate:Registrate:${ registrate_version} " ))
139- compileOnly(annotationProcessor(" io.github.llamalad7:mixinextras-common:0.4.1" ))
140- implementation(" io.github.llamalad7:mixinextras-forge:0.4.1" )
141-
142- // JEI
143- // compile against the JEI API but do not include it at runtime
144- compileOnly(fg. deobf(" mezz.jei:jei-${ minecraft_version} -common-api:${ jei_version} " ))
145- compileOnly(fg. deobf(" mezz.jei:jei-${ minecraft_version} -forge-api:${ jei_version} " ))
146- // at runtime, use the full JEI jar for Forge
147- runtimeOnly(fg. deobf(" mezz.jei:jei-${ minecraft_version} -forge:${ jei_version} " ))
148-
149- // curios
158+ implementation(" com.simibubi.create:create-${ minecraft_version} :${ create_version} :slim" ){ transitive = false }
159+ implementation(" net.createmod.ponder:Ponder-NeoForge-${ minecraft_version} :${ ponder_version} " )
160+ compileOnly(" dev.engine-room.flywheel:flywheel-neoforge-api-${ minecraft_version} :${ flywheel_version} " )
161+ runtimeOnly(" dev.engine-room.flywheel:flywheel-neoforge-${ minecraft_version} :${ flywheel_version} " )
162+ implementation(" com.tterrag.registrate:Registrate:${ registrate_version} " )
150163
151- runtimeOnly fg. deobf(" top.theillusivec4.curios:curios-forge:${ curios_version} " )
152- compileOnly fg. deobf(" top.theillusivec4.curios:curios-forge:${ curios_version} :api" )
164+ // JEI
165+ compileOnly(" mezz.jei:jei-${ minecraft_version} -common-api:${ jei_version} " )
166+ compileOnly(" mezz.jei:jei-${ minecraft_version} -neoforge-api:${ jei_version} " )
167+ runtimeOnly(" mezz.jei:jei-${ minecraft_version} -neoforge:${ jei_version} " )
153168
154- annotationProcessor " org.spongepowered:mixin:${ mixin_version} :processor"
155169
156170 // unit test tool
157171 testImplementation ' org.junit.jupiter:junit-jupiter-api:5.10.0'
@@ -160,13 +174,7 @@ dependencies {
160174 implementation(" org.knowm.xchart:xchart:3.2.2" )
161175
162176}
163- mixin {
164- add sourceSets. main, ' formicapi.refmap.json'
165- config ' formicapi.mixins.json'
166177
167- // debug.verbose = true
168- // debug.export = true
169- }
170178// This block of code expands all declared replace properties in the specified resource targets.
171179// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
172180// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
@@ -214,29 +222,76 @@ tasks.test {
214222// dependsOn 'reobfJar'
215223// }
216224
217- // Example configuration to allow publishing using the maven-publish plugin
218225publishing {
219226 publications {
220- register(' mavenJava' , MavenPublication ) {
221- artifactId = ' formic-api-' + minecraft_version // <-- valid Maven ID (no spaces)
222- groupId = ' com.rae.formicapi' // <-- choose your group
223- version = mod_version // <-- version of your mod/library
224-
225- artifact jar
227+ mavenJava(MavenPublication ) {
228+ from components. java
229+ }
230+ }
231+ }
226232
233+ // the jreleaser doesn't work
234+ // todo find why and fix it
235+ jreleaser {
236+ project {
237+ name = ' FormicAPI'
238+ version = mod_version
239+ description = ' A Minecraft modding API for the Engineer Colony'
240+ authors = [' RealAntEngineer' ]
241+ license = ' MIT'
242+ // Project homepage
243+ java {
244+ version = ' 17'
227245 }
246+ website = ' https://github.com/RealAntEngineer/FormicAPI'
228247 }
229- repositories {// TODO use a more practical
248+
249+ deploy {
230250 maven {
231- url = uri(" https://maven.pkg.github.com/RealAntEngineer/Formic_API" )
232- credentials {
233- username = System . getProperty(" USERNAME" )
234- password = System . getProperty(" TOKEN" )
251+ mavenCentral {
252+ main {
253+ active = ' ALWAYS'
254+ url = ' https://s01.oss.sonatype.org/services/staging/deploy/maven2/' // new token-based endpoint
255+
256+ username = System . getProperty(' SONATYPE_USERNAME' )
257+ password = System . getProperty(' SONATYPE_TOKEN' )
258+ }
235259 }
236260 }
237261 }
238- }
262+ signing {
263+ // active = 'ALWAYS'
264+ // armored = true
265+ // mode = 'MEMORY'
266+ secretKey = System . getProperty(' SONATYPE_USERNAME' )
267+ passphrase = System . getProperty(' SONATYPE_TOKEN' )
268+ }
239269
270+ distributions {
271+ main {
272+ artifact {
273+ path = " $buildDir /libs/formic-api-${ minecraft_version} .jar"
274+ }
275+ extraProperties. put(' groupId' , ' io.github.realantengineer.formicapi' )
276+ extraProperties. put(' artifactId' , " formic-api-${ minecraft_version} " )
277+ extraProperties. put(' version' , mod_version)
278+ }
279+ }
280+ /* release {
281+ github {
282+ active = 'NEVER'
283+ }
284+ }*/
285+ }
240286tasks. withType(JavaCompile ). configureEach {
241287 options. encoding = ' UTF-8' // Use the UTF-8 charset for Java compilation
242- }
288+ }
289+
290+
291+ // IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
292+ idea {
293+ module {
294+ downloadSources = true
295+ downloadJavadoc = true
296+ }
297+ }
0 commit comments