118 lines
3.7 KiB
Plaintext
118 lines
3.7 KiB
Plaintext
import io.gitlab.jfronny.scripts.*
|
|
|
|
plugins {
|
|
id("jf.autoversion")
|
|
id("jf.maven-publish")
|
|
id("lom")
|
|
}
|
|
|
|
val splitRegex = Regex(", ?")
|
|
fun String.splitByComma() = splitRegex.split(this).filter { it.isNotBlank() }
|
|
|
|
val devOnlyModules by extra(prop("dev_only_module", "").splitByComma())
|
|
val nonModSubprojects by extra(prop("non_mod_project", "").splitByComma())
|
|
val self = project
|
|
if (hasProperty("maven_group")) group = prop("maven_group")
|
|
|
|
allprojects {
|
|
if (name in nonModSubprojects) return@allprojects
|
|
|
|
group = self.group
|
|
version = self.version
|
|
|
|
apply(plugin = "jf.maven-publish")
|
|
apply(plugin = "lom")
|
|
|
|
base {
|
|
archivesName.set(prop("archives_base_name", archivesName.get()))
|
|
}
|
|
|
|
lom {
|
|
minecraftVersion.set(prop("minecraft_version"))
|
|
loaderVersion.set(prop("loader_version"))
|
|
if (hasProperty("yarn_mappings")) yarn(prop("yarn_mappings"))
|
|
else mojmap()
|
|
}
|
|
|
|
if (hasProperty("libjf_version")) {
|
|
dependencies {
|
|
clientAnnotationProcessor(annotationProcessor("io.gitlab.jfronny.libjf:libjf-config-compiler-plugin-v2:${prop("libjf_version")}")!!)
|
|
}
|
|
|
|
tasks.withType<JavaCompile> {
|
|
options.compilerArgs.add("-AmodId=" + base.archivesName.get())
|
|
}
|
|
}
|
|
|
|
afterEvaluate {
|
|
self.allprojects.forEach { sub ->
|
|
if (sub != this && sub.name !in nonModSubprojects) {
|
|
loom {
|
|
mods {
|
|
register(sub.name) {
|
|
sourceSet(sub.sourceSets.main.get())
|
|
sourceSet(sub.sourceSets.client.get())
|
|
}
|
|
if (!sourceSets.testmod.get().resources.isEmpty) {
|
|
register("${sub.name}-testmod") {
|
|
sourceSet(sub.sourceSets.testmod.get())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
subprojects {
|
|
if (name in nonModSubprojects) return@subprojects
|
|
|
|
self.tasks.deployDebug.dependsOn(tasks.deployDebug)
|
|
self.tasks.deployRelease.dependsOn(tasks.deployRelease)
|
|
|
|
tasks.named("javadoc") { enabled = false }
|
|
|
|
if (name !in devOnlyModules && !sourceSets.testmod.get().resources.isEmpty) {
|
|
//TODO register testmods of subprojects as testmodInclude automatically
|
|
// val configuration = configurations.create("testmodJar").name
|
|
// val testmodJarTask = tasks.named<Jar>("testmodJar").get()
|
|
// artifacts.add(configuration, testmodJarTask.archiveFile.get().asFile) {
|
|
// type = "jar"
|
|
// builtBy(testmodJarTask)
|
|
// }
|
|
//
|
|
// self.dependencies {
|
|
// testmodInclude(project(mapOf("path" to path, "configuration" to configuration)))
|
|
// }
|
|
}
|
|
|
|
self.dependencies {
|
|
api(project(mapOf("path" to project.path, "configuration" to "shadow")))
|
|
clientImplementation(sourceSets.client.get().output)
|
|
testmodImplementation(sourceSets.testmod.get().output)
|
|
|
|
if (name !in devOnlyModules) include(project)
|
|
}
|
|
}
|
|
|
|
val moveArtifacts by tasks.registering(Copy::class) {
|
|
val suffix = if (flavour.isEmpty()) "" else "-$flavour"
|
|
|
|
val sources = mapOf("latest$suffix.jar" to tasks.remapJar, "latest$suffix-dev.jar" to tasks.shadowJar)
|
|
|
|
for (source in sources) {
|
|
from(source.value.map { it.archiveFile }) {
|
|
this.rename { source.key }
|
|
}
|
|
dependsOn(source.value)
|
|
}
|
|
|
|
into(buildDir.resolve("artifacts"))
|
|
}
|
|
|
|
tasks.deployDebug.dependsOn(moveArtifacts)
|
|
|
|
if (hasProperty("curseforge_id")) apply(plugin = "jfmod.curseforge")
|
|
if (hasProperty("modrinth_id")) apply(plugin = "jfmod.modrinth")
|