66 lines
2.9 KiB
Kotlin
66 lines
2.9 KiB
Kotlin
package io.gitlab.jfronny.scripts
|
|
|
|
import org.gradle.api.Action
|
|
import org.gradle.api.Project
|
|
import org.gradle.api.provider.ListProperty
|
|
import org.gradle.api.provider.Property
|
|
import org.gradle.api.tasks.Nested
|
|
import org.jetbrains.annotations.ApiStatus.Internal
|
|
|
|
interface JfModExtension: LomExtension {
|
|
val libJfVersion: Property<String>
|
|
val fabricApiVersion: Property<String>
|
|
@get:Nested val curseforge: CurseForge
|
|
@get:Nested val modrinth: Modrinth
|
|
|
|
@Internal
|
|
override fun check(proj: Project) {
|
|
super.check(proj)
|
|
libJfVersion.finalizeValue()
|
|
fabricApiVersion.finalizeValue()
|
|
modrinth.check(proj)
|
|
curseforge.check(proj)
|
|
}
|
|
|
|
fun isMod(proj: Project) = proj.extensions.findByName("jfModule") != null
|
|
fun isFabric(proj: Project) = if (proj == this) isFabric else (proj.extensions.findByName("lom") as? LomExtension)?.isFabric ?: false
|
|
fun isForge(proj: Project) = if (proj == this) isForge else (proj.extensions.findByName("lom") as? LomExtension)?.isNeoForge ?: false
|
|
fun isNeoForge(proj: Project) = if (proj == this) isNeoForge else (proj.extensions.findByName("lom") as? LomExtension)?.isNeoForge ?: false
|
|
fun isSplitSources(proj: Project) = if (proj == this) isSplitSources else (proj.extensions.findByName("lom") as? LomExtension)?.isSplitSources ?: false
|
|
fun curseforge(closure: Action<CurseForge>) = closure.execute(curseforge)
|
|
fun modrinth(closure: Action<Modrinth>) = closure.execute(modrinth)
|
|
|
|
interface CurseForge {
|
|
val projectId: Property<String>
|
|
val requiredDependencies: ListProperty<String>
|
|
val optionalDependencies: ListProperty<String>
|
|
|
|
@Internal
|
|
fun check(proj: Project) {
|
|
projectId.finalizeValue()
|
|
requiredDependencies.finalizeValue()
|
|
optionalDependencies.finalizeValue()
|
|
if (!projectId.isPresent) {
|
|
require(requiredDependencies.map { it.isEmpty() }.getOrElse(true)) { "curseforge is not configured for a project id but has dependencies" }
|
|
require(optionalDependencies.map { it.isEmpty() }.getOrElse(true)) { "curseforge is not configured for a project id but has dependencies" }
|
|
}
|
|
}
|
|
}
|
|
|
|
interface Modrinth {
|
|
val projectId: Property<String>
|
|
val requiredDependencies: ListProperty<String>
|
|
val optionalDependencies: ListProperty<String>
|
|
|
|
@Internal
|
|
fun check(proj: Project) {
|
|
projectId.finalizeValue()
|
|
requiredDependencies.finalizeValue()
|
|
optionalDependencies.finalizeValue()
|
|
if (!projectId.isPresent) {
|
|
require(requiredDependencies.map { it.isEmpty() }.getOrElse(true)) { "modrinth is not configured for a project id but has dependencies" }
|
|
require(optionalDependencies.map { it.isEmpty() }.getOrElse(true)) { "modrinth is not configured for a project id but has dependencies" }
|
|
}
|
|
}
|
|
}
|
|
} |