fix: special-case forge
This commit is contained in:
parent
19c9317a54
commit
034e995cb3
|
@ -23,6 +23,8 @@ interface JfModExtension: LomExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isMod(proj: Project) = proj.extensions.findByName("jfModule") != null
|
fun isMod(proj: Project) = proj.extensions.findByName("jfModule") != null
|
||||||
|
fun isFabric(proj: Project) = (proj.extensions.findByName("lom") as? LomExtension)?.isFabric ?: false
|
||||||
|
fun isForge(proj: Project) = (proj.extensions.findByName("lom") as? LomExtension)?.isForge ?: false
|
||||||
fun curseforge(closure: Action<CurseForge>) = closure.execute(curseforge)
|
fun curseforge(closure: Action<CurseForge>) = closure.execute(curseforge)
|
||||||
fun modrinth(closure: Action<Modrinth>) = closure.execute(modrinth)
|
fun modrinth(closure: Action<Modrinth>) = closure.execute(modrinth)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
import gradle.kotlin.dsl.accessors._2b47c59e4bff1a1e15af40cb0a9df00c.modImplementation
|
|
||||||
import gradle.kotlin.dsl.accessors._2b47c59e4bff1a1e15af40cb0a9df00c.modLocalRuntime
|
|
||||||
import gradle.kotlin.dsl.accessors._2b47c59e4bff1a1e15af40cb0a9df00c.versionCatalogs
|
|
||||||
import io.gitlab.jfronny.scripts.*
|
import io.gitlab.jfronny.scripts.*
|
||||||
import org.gradle.api.internal.project.ProjectStateInternal
|
import org.gradle.api.internal.project.ProjectStateInternal
|
||||||
import org.gradle.api.tasks.compile.JavaCompile
|
import org.gradle.api.tasks.compile.JavaCompile
|
||||||
|
@ -13,9 +10,10 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
val args = extensions.create<JfModuleExtension>("jfModule")
|
val args = extensions.create<JfModuleExtension>("jfModule")
|
||||||
|
val lomArgs: LomExtension by extensions
|
||||||
|
|
||||||
val isRoot = project == rootProject
|
val isRoot = project == rootProject
|
||||||
val rootArgs get() = rootProject.extensions.getByName<JfModExtension>("jfMod")
|
val rootArgs: JfModExtension by rootProject.extensions
|
||||||
|
|
||||||
insertEarlyAfterEvaluate {
|
insertEarlyAfterEvaluate {
|
||||||
args.check(project)
|
args.check(project)
|
||||||
|
@ -52,10 +50,6 @@ insertEarlyAfterEvaluate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
versionCatalogs {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Project.pAfterEvaluate(action: (Project) -> Unit) =
|
fun Project.pAfterEvaluate(action: (Project) -> Unit) =
|
||||||
if ((this.state as ProjectStateInternal).hasCompleted()) action(this)
|
if ((this.state as ProjectStateInternal).hasCompleted()) action(this)
|
||||||
else afterEvaluate { action(this) }
|
else afterEvaluate { action(this) }
|
||||||
|
@ -64,19 +58,22 @@ afterEvaluate {
|
||||||
rootProject.allprojects.forEach {
|
rootProject.allprojects.forEach {
|
||||||
it.pAfterEvaluate { sub ->
|
it.pAfterEvaluate { sub ->
|
||||||
if (sub != this && rootArgs.isMod(sub)) {
|
if (sub != this && rootArgs.isMod(sub)) {
|
||||||
loom {
|
if (rootArgs.isFabric(sub) && lomArgs.isFabric) {
|
||||||
mods {
|
loom {
|
||||||
register(sub.name) {
|
mods {
|
||||||
sourceSet(sub.sourceSets.main.get())
|
register(sub.name) {
|
||||||
sourceSet(sub.sourceSets.client.get())
|
sourceSet(sub.sourceSets.main.get())
|
||||||
}
|
sourceSet(sub.sourceSets.client.get())
|
||||||
if (!sourceSets.testmod.get().resources.isEmpty) {
|
}
|
||||||
register("${sub.name}-testmod") {
|
if (!sourceSets.testmod.get().resources.isEmpty) {
|
||||||
sourceSet(sub.sourceSets.testmod.get())
|
register("${sub.name}-testmod") {
|
||||||
|
sourceSet(sub.sourceSets.testmod.get())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//TODO handle forge
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,11 +94,14 @@ afterEvaluate {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isRoot) rootProject.dependencies {
|
if (!isRoot) rootProject.dependencies {
|
||||||
api(project(path = project.path, configuration = "shadow"))
|
if (rootArgs.isFabric && lomArgs.isFabric) {
|
||||||
clientImplementation(sourceSets.client.get().output)
|
api(project(path = project.path, configuration = "shadow"))
|
||||||
testmodImplementation(sourceSets.testmod.get().output)
|
clientImplementation(sourceSets.client.get().output)
|
||||||
|
testmodImplementation(sourceSets.testmod.get().output)
|
||||||
|
|
||||||
if (!devOnly) include(project)
|
if (!devOnly) include(project)
|
||||||
|
}
|
||||||
|
//TODO handle forge
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,3 +21,6 @@ val TaskContainer.genCommonSources get() = named<DefaultTask>("genCommonSources"
|
||||||
val TaskContainer.sourcesJar get() = named<Jar>("sourcesJar")
|
val TaskContainer.sourcesJar get() = named<Jar>("sourcesJar")
|
||||||
|
|
||||||
fun DependencyHandler.devProject(path: String): Dependency = project(path, "dev")
|
fun DependencyHandler.devProject(path: String): Dependency = project(path, "dev")
|
||||||
|
|
||||||
|
val LomExtension.isFabric: Boolean get() = fabricLoaderVersion.isPresent
|
||||||
|
val LomExtension.isForge: Boolean get() = neoforgeVersion.isPresent
|
Loading…
Reference in New Issue