fix: maybe add testmod dependency properly
All checks were successful
ci/woodpecker/push/gradle Pipeline was successful
ci/woodpecker/push/pages Pipeline was successful

This commit is contained in:
Johannes Frohnmeyer 2024-07-21 17:34:43 +02:00
parent 26f31906bb
commit 05af344da2
Signed by: Johannes
GPG Key ID: E76429612C2929F4
2 changed files with 19 additions and 15 deletions

View File

@ -65,22 +65,19 @@ afterEvaluate {
rootProject.allprojects.forEach {
it.pAfterEvaluate { sub ->
if (sub != this && rootArgs.isMod(sub)) {
if (rootArgs.isFabric(sub) && lomArgs.isFabric) {
loom {
mods {
register(sub.name) {
sourceSet(sub.sourceSets.main.get())
if (rootArgs.isSplitSources(sub)) sourceSet(sub.sourceSets.client.get())
}
if (!sourceSets.testmod.get().resources.isEmpty) {
register("${sub.name}-testmod") {
sourceSet(sub.sourceSets.testmod.get())
}
loom {
mods {
register(sub.name) {
sourceSet(sub.sourceSets.main.get())
if (rootArgs.isSplitSources(sub)) sourceSet(sub.sourceSets.client.get())
}
if (!sourceSets.testmod.get().resources.isEmpty) {
register("${sub.name}-testmod") {
sourceSet(sub.sourceSets.testmod.get())
}
}
}
}
//TODO handle forge
}
}
}
@ -103,7 +100,7 @@ afterEvaluate {
if (!isRoot) rootProject.dependencies {
api(project(path = project.path, configuration = "shadow"))
if (lomArgs.isSplitSources) clientImplementation(sourceSets.client.get().output)
testmodImplementation(sourceSets.testmod.get().output)
testmodImplementation(project(mapOf("path" to project.path, "configuration" to "testmod")))
if (!devOnly) include(project)
}

View File

@ -205,7 +205,11 @@ tasks.publish { dependsOn(tasks.build) }
tasks.deployDebug.dependsOn(tasks.publish)
// create testmodInclude configuration
val testmodIncludeConfiguration = configurations.create("testmodInclude")
val testmodInclude by configurations.creating
val testmod by configurations.creating {
isCanBeConsumed = true
isCanBeResolved = false
}
if (hasTestmod) {
// generate jar from testmod source set
@ -214,6 +218,9 @@ if (hasTestmod) {
destinationDirectory.set(devlibs)
archiveClassifier.set("testmod")
}
artifacts {
add(testmod.name, testmodJar)
}
afterEvaluate {
// remap configuration for outputting usable testmod jar
@ -223,7 +230,7 @@ if (hasTestmod) {
archiveClassifier.set("testmod")
// add nested jars from testmodInclude
addNestedDependencies.set(true)
nestedJars.setFrom(*testmodIncludeConfiguration.files.toTypedArray())
nestedJars.setFrom(*testmodInclude.files.toTypedArray())
}
tasks.assemble { dependsOn(remapTestmodJar) }
}