11plugins {
2- id ' net.neoforged.gradle.userdev ' version ' 7 .0.185 '
3- id ' net.darkhax.curseforgegradle' version ' 1.1.26 '
2+ id ' net.neoforged.moddev ' version ' 2 .0.119 '
3+ id ' net.darkhax.curseforgegradle' version ' 1.1.28 '
44 id ' com.github.kt3k.coveralls' version ' 2.12.0'
55 id ' com.diffplug.spotless' version ' 6.25.0'
66 id ' com.github.johnrengelman.shadow' version ' 8.1.1'
@@ -14,7 +14,6 @@ apply plugin: 'jacoco'
1414
1515import net.darkhax.curseforgegradle.Constants
1616import net.darkhax.curseforgegradle.TaskPublishCurseForge
17- import net.neoforged.gradle.common.tasks.PotentiallySignJar
1817
1918// Determine build number
2019String build_number = " DEV" // this will be referenced as simply build_number from now on.
@@ -95,6 +94,7 @@ configurations {
9594
9695test {
9796 testLogging {
97+ events org.gradle.api.tasks.testing.logging.TestLogEvent . STANDARD_OUT
9898 exceptionFormat = ' full'
9999 }
100100}
@@ -113,7 +113,13 @@ repositories {
113113}
114114
115115dependencies {
116- implementation " net.neoforged:neoforge:${ project.neoforge_version} "
116+ testImplementation ' org.junit.jupiter:junit-jupiter:5.7.1'
117+ testImplementation ' org.junit.jupiter:junit-jupiter-params:5.7.1'
118+ testImplementation ' org.junit.platform:junit-platform-suite-api:1.14.1'
119+ testImplementation ' org.hamcrest:hamcrest:2.1'
120+ testImplementation " org.mockito:mockito-core:2.+"
121+ testRuntimeOnly ' org.junit.platform:junit-platform-suite-engine'
122+ testRuntimeOnly ' org.junit.platform:junit-platform-launcher'
117123
118124 // Add something like 'cyclopscore_version_local=0.1.0-DEV' to your secrets.properties if you want to use a custom local CyclopsCore version.
119125 if (secrets. cyclopscore_version_local) {
@@ -150,46 +156,55 @@ dependencies {
150156 exclude group : ' com.ibm.icu' , module : ' icu4j'
151157 }
152158 shadow " org.graalvm.js:js:${ project.graal_version} "
153-
154- testImplementation " junit:junit:4.12"
155- testImplementation " org.mockito:mockito-core:1.+"
156- testRuntimeOnly " org.junit.vintage:junit-vintage-engine:5.8.2"
157159}
158160
159- subsystems {
160- parchment {
161- minecraftVersion = " ${ project.parchment_minecraft_version} "
162- mappingsVersion = " ${ project.parchment_version} "
163- }
161+ test {
162+ useJUnitPlatform()
164163}
165164
166- runs {
167- configureEach {
168- systemProperty ' forge.logging.markers' , ' REGISTRIES'
169- systemProperty ' forge.logging.console.level' , ' debug'
170- systemProperty ' forge.logging.console.level' , ' debug'
171- modSource project. sourceSets. main
165+ neoForge {
166+ version = " ${ neoforge_version} "
172167
173- dependencies {
174- runtime project . configurations . modLib
175- }
168+ parchment {
169+ mappingsVersion = " ${ parchment_version } "
170+ minecraftVersion = " ${ parchment_minecraft_version } "
176171 }
177-
178- client {
179- systemProperty ' neoforge.enabledGameTestNamespaces' , " cyclopscore,${ mod_id} "
172+
173+ // Automatically enable neoforge AccessTransformers if the file exists
174+ def at = file(' src/main/resources/META-INF/accesstransformer.cfg' )
175+ if (at. exists()) {
176+ accessTransformers = [ at. absolutePath ]
180177 }
181178
182- server {
183- systemProperty ' neoforge.enabledGameTestNamespaces' , " cyclopscore,${ mod_id} "
184- argument ' --nogui'
179+ validateAccessTransformers = true
180+
181+ runs {
182+ client {
183+ client()
184+ }
185+ server {
186+ server()
187+ programArgument ' --nogui'
188+ }
189+ gameTestServer {
190+ type = " gameTestServer"
191+ }
192+ configureEach {
193+ systemProperty ' forge.logging.markers' , ' REGISTRIES'
194+ logLevel = org.slf4j.event.Level . DEBUG
195+ systemProperty ' neoforge.enabledGameTestNamespaces' , " cyclopscore,${ mod_id} "
196+ }
185197 }
186198
187- gameTestServer {
188- systemProperty ' neoforge.enabledGameTestNamespaces' , " cyclopscore,${ mod_id} "
199+ mods {
200+ " ${ mod_id} " {
201+ sourceSet(sourceSets. main)
202+ }
189203 }
190204
191- clientData {
192- arguments. addAll ' --mod' , project. mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ). getAbsolutePath(), ' --existing' , file(' src/main/resources/' ). getAbsolutePath()
205+ unitTest {
206+ enable()
207+ testedMod = mods. integratedscripting
193208 }
194209}
195210
@@ -208,21 +223,6 @@ jar {
208223 }
209224}
210225
211- task signJar (type : PotentiallySignJar , dependsOn : jar) {
212- dependsOn(tasks. jar)
213-
214- onlyIf {
215- System . getenv(). SIGN_KEYSTORE
216- }
217-
218- keyStore = System . getenv(). SIGN_KEYSTORE
219- alias = System . getenv(). SIGN_ALIAS
220- storePass = System . getenv(). SIGN_STOREPASS
221- keyPass = System . getenv(). SIGN_KEYPASS
222- input = jar. archivePath
223- output = jar. archivePath
224- }
225-
226226task deobfJar (type : Jar ) {
227227 from sourceSets. main. output
228228 archiveClassifier. set(' deobf' )
@@ -392,14 +392,10 @@ jacocoTestReport {
392392}
393393
394394// Also measure coverage for game tests
395- tasks. whenTaskAdded { task ->
396- if (task. name. equals(' runGameTestServer' )) {
397- jacocoTestReport. dependsOn test, task
398- jacoco {
399- toolVersion = " 0.8.12"
400- applyTo task
401- }
402- }
395+ jacocoTestReport. dependsOn test, runGameTestServer
396+ jacoco {
397+ toolVersion = " 0.8.12"
398+ applyTo runGameTestServer
403399}
404400
405401spotless {
@@ -422,19 +418,3 @@ compileJava.dependsOn updateGitHooks
422418tasks. withType(JavaCompile ). configureEach {
423419 options. encoding = ' UTF-8' // Use the UTF-8 charset for Java compilation
424420}
425-
426- // The following is required to fix running unit tests during build phase
427- tasks. configureEach { task ->
428- if (task. name. startsWith(" test" )) {
429- task. enabled = true
430- }
431- if (task. name. startsWith(" testJunit" )) {
432- task. enabled = false
433- }
434- }
435-
436- task benchmark (type : JavaExec ) {
437- classpath sourceSets. test. runtimeClasspath
438- main = " org.cyclops.integratedscripting.evaluate.translation.BenchmarkValueTranslators"
439- }
440- test. dependsOn benchmark
0 commit comments