@@ -18,7 +18,7 @@ plugins {
1818 id(' eclipse' )
1919 id(' idea' )
2020 id(' maven-publish' )
21- id(' net.neoforged.gradle.userdev' ) version(' 7.0.134 ' )// https://projects.neoforged.net/neoforged/neogradle
21+ id(' net.neoforged.gradle.userdev' ) version(' 7.0.136 ' )// https://projects.neoforged.net/neoforged/neogradle
2222}
2323
2424tasks. named(' wrapper' , Wrapper ). configure {
@@ -63,46 +63,35 @@ sourceSets {
6363 srcDirs + = [' src/datagen/generated/mekanism' ]
6464 }
6565 compileClasspath + = api. output
66- runtimeClasspath + = api. output
6766 }
6867 test {
6968 // The test module has no resources
7069 resources. srcDirs = []
7170 // Add the api to the output, all other ones that need to will get added via setupExtraSourceSets
7271 compileClasspath + = api. output
73- runtimeClasspath + = api. output
7472 }
7573 gameTest {
7674 runs {
7775 modIdentifier = ' mekanismtests'
7876 }
7977 compileClasspath + = api. output
80- runtimeClasspath + = api. output
8178 }
8279}
8380
8481configurations {
85- // Sets up a dependency configuration called 'localRuntime'.
86- // This configuration should be used instead of 'runtimeOnly' to declare
87- // a dependency that will be present for runtime testing but that is
88- // "optional", meaning it will not be pulled by dependents of this mod.
89- runtimeClasspath . extendsFrom(localRuntime )
90-
82+ // Make sure all our sub source set stuff extends the proper base methods so that
83+ // they can see all the dependencies we have in dependencies including neo
84+ extendConfigurations(implementation, apiImplementation, testImplementation)
85+ extendConfigurations(compileOnly, apiCompileOnly, testCompileOnly)
86+ extendConfigurations(runtimeOnly, apiRuntimeOnly )
87+ extendConfigurations(localRuntime, apiLocalRuntime)
9188 datagenNonMod
9289}
9390
9491// Add all extra source sets that the main sourceSet should have
9592setupExtraSourceSets(sourceSets. main)
9693setupExtraSourceSets(sourceSets. gameTest, false )
9794
98- configurations {
99- // Make sure all our sub source set stuff extends the proper base methods so that
100- // they can see all the dependencies we have in dependencies including forge
101- extendConfigurations(implementation, apiImplementation, testImplementation)
102- extendConfigurations(compileOnly, apiCompileOnly, testCompileOnly)
103- extendConfigurations(runtimeOnly, apiRuntimeOnly)
104- }
105-
10695// Create sourceSets and configurations for each of the additional modules in src/$name and adds a reference to
10796// the corresponding data gen's resource directory excluding the cache. It also adds the api and main mekanism
10897// module to the dependencies of the source set we are setting up, and sets up all extra source sets that are
@@ -127,21 +116,21 @@ for (String name : secondaryModules) {
127116def setupExtraSourceSets (SourceSet base , boolean includeExtra = true ) {
128117 // Expose the base module to junit
129118 project. sourceSets. test. compileClasspath + = base. output
130- project. sourceSets. test. runtimeClasspath + = base. output
131119 if (base != project. sourceSets. gameTest) {
132120 project. sourceSets. gameTest. compileClasspath + = base. output
133- project. sourceSets. gameTest. runtimeClasspath + = base. output
134121 }
135122 // Setup and extend configurations for alternate modules. First by making the implementation, compileOnly, runtimeOnly equivalents
136123 // for those modules extend the main ones
137124 def baseImplementation = project. configurations. maybeCreate(base. getTaskName(null , ' implementation' ))
138125 def baseCompileOnly = project. configurations. maybeCreate(base. getTaskName(null , ' compileOnly' ))
139126 def baseRuntimeOnly = project. configurations. maybeCreate(base. getTaskName(null , ' runtimeOnly' ))
127+ def baseLocalRuntime = project. configurations. maybeCreate(base. getTaskName(null , ' localRuntime' ))
140128 if (base != project. sourceSets. main) {
141129 // If this is a secondary module then make the base tasks extend the builtin ones
142130 baseImplementation. extendsFrom(project. configurations. getByName(' implementation' ))
143131 baseCompileOnly. extendsFrom(project. configurations. getByName(' compileOnly' ))
144132 baseRuntimeOnly. extendsFrom(project. configurations. getByName(' runtimeOnly' ))
133+ baseLocalRuntime. extendsFrom(project. configurations. getByName(' localRuntime' ))
145134 }
146135 if (includeExtra) {
147136 // And then setup and have all the extra sourceSets have their configurations extend the ones for the base module so that they can
@@ -157,6 +146,7 @@ def setupExtraSourceSets(SourceSet base, boolean includeExtra = true) {
157146 project. configurations. maybeCreate(extraSourceSet. getTaskName(null , ' implementation' )). extendsFrom(* implExtends)
158147 project. configurations. maybeCreate(extraSourceSet. getTaskName(null , ' compileOnly' )). extendsFrom(baseCompileOnly)
159148 project. configurations. maybeCreate(extraSourceSet. getTaskName(null , ' runtimeOnly' )). extendsFrom(baseRuntimeOnly)
149+ project. configurations. maybeCreate(extraSourceSet. getTaskName(null , ' localRuntime' )). extendsFrom(baseLocalRuntime)
160150 }
161151 }
162152}
@@ -348,6 +338,9 @@ runs {
348338 setupClientAcc(run)
349339 modSources. add((SourceSet ) sourceSets. gameTest)
350340 }
341+ junit {
342+ unitTestSources. add((SourceSet ) sourceSets. test)
343+ }
351344 data {
352345 programArguments. addAll((String []) [' --all' , ' --output' , file(' src/datagen/generated/' ). getAbsolutePath(),
353346 ' --mod' , ' mekanism' , ' --existing' , file(' src/main/resources/' ). getAbsolutePath()])
@@ -402,8 +395,9 @@ repositories { RepositoryHandler handler ->
402395 exclusiveRepo(handler, ' https://maven.parchmentmc.org/' , ' org.parchmentmc.data' )
403396}
404397
405- tasks. named(' test' , Test ) {
406- useJUnitPlatform()
398+ tasks. named(' test' ). configure {
399+ // Disable builtin test task as we use and build uses testJunit so there is no point in having it also attempt to run an empty test task
400+ enabled(false )
407401}
408402
409403dependencies {
@@ -413,7 +407,9 @@ dependencies {
413407 localRuntime(project(' :annotation-processor' ))
414408 annotationProcessor(project(' :annotation-processor' ))
415409
416- gameTestImplementation(" net.neoforged:testframework:${ forge_version} " )
410+ def testFrameWork = " net.neoforged:testframework:${ forge_version} "
411+ gameTestImplementation(testFrameWork)
412+ testImplementation(testFrameWork)
417413 testImplementation(" org.junit.jupiter:junit-jupiter-api:${ junit_version} " )
418414 testRuntimeOnly(" org.junit.jupiter:junit-jupiter-engine:${ junit_version} " )
419415 // We use https://github.com/quicktheories/QuickTheories to allow for implementing property based testing
0 commit comments