Some TODOs
This commit is contained in:
parent
88cc5e36e9
commit
b5adf70424
|
@ -61,8 +61,10 @@ allprojects {
|
|||
sourceSet(sub.sourceSets.main)
|
||||
sourceSet(sub.sourceSets.client)
|
||||
}
|
||||
register("${sub.name}-testmod") {
|
||||
sourceSet(sub.sourceSets.testmod)
|
||||
if (!sourceSets.testmod.resources.isEmpty) {
|
||||
register("${sub.name}-testmod") {
|
||||
sourceSet(sub.sourceSets.testmod)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,25 +81,35 @@ subprojects {
|
|||
|
||||
tasks.named("javadoc").get().enabled = false
|
||||
|
||||
afterEvaluate {
|
||||
dependencies {
|
||||
testmodImplementation(sourceSets.main.output)
|
||||
}
|
||||
if (name !in devOnlyModules && !sourceSets.testmod.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.output)
|
||||
testmodImplementation(sourceSets.testmod.output)
|
||||
|
||||
if (name !in devOnlyModules) include(project)
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
tasks.genClientOnlySources.enabled = false
|
||||
tasks.genCommonSources.enabled = false
|
||||
tasks.unpickClientOnlyJar.enabled = false
|
||||
tasks.unpickCommonJar.enabled = false
|
||||
|
||||
rootProject.dependencies {
|
||||
api(project(mapOf("path" to project.path, "configuration" to "shadow")))
|
||||
clientImplementation(sourceSets.client.output)
|
||||
testmodImplementation(sourceSets.testmod.output)
|
||||
|
||||
if (name !in devOnlyModules) include(project)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasProperty("curseforge_id")) apply(plugin = "jfmod.curseforge")
|
||||
if (hasProperty("modrinth_id")) apply(plugin = "jfmod.modrinth")
|
||||
if (hasProperty("modrinth_id")) apply(plugin = "jfmod.modrinth")
|
||||
|
|
|
@ -47,17 +47,6 @@ class LomPlugin @Inject constructor(private val softwareComponentFactory: Softwa
|
|||
loom {
|
||||
runtimeOnlyLog4j.set(true)
|
||||
splitEnvironmentSourceSets()
|
||||
|
||||
// Class path groups (required to allow ultra early init)
|
||||
mods {
|
||||
register(name) {
|
||||
sourceSet(sourceSets.main)
|
||||
sourceSet(sourceSets.client)
|
||||
}
|
||||
register("$name-testmod") {
|
||||
sourceSet(sourceSets.testmod)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create testmod source set with access to main and client classpaths
|
||||
|
@ -71,6 +60,40 @@ class LomPlugin @Inject constructor(private val softwareComponentFactory: Softwa
|
|||
}
|
||||
}
|
||||
|
||||
val hasTestmod = !sourceSets.testmod.resources.isEmpty
|
||||
|
||||
// Class path groups (required to allow ultra early init)
|
||||
loom {
|
||||
mods {
|
||||
register(name) {
|
||||
sourceSet(sourceSets.main)
|
||||
sourceSet(sourceSets.client)
|
||||
}
|
||||
if (hasTestmod) {
|
||||
register("$name-testmod") {
|
||||
sourceSet(sourceSets.testmod)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasTestmod) {
|
||||
runs {
|
||||
create("testmodClient") {
|
||||
client()
|
||||
ideConfigGenerated(rootProject == project)
|
||||
name("Testmod Client")
|
||||
source(sourceSets.testmod)
|
||||
}
|
||||
create("testmodServer") {
|
||||
server()
|
||||
ideConfigGenerated(rootProject == project)
|
||||
name("Testmod Server")
|
||||
source(sourceSets.testmod)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Common repositories for mods
|
||||
repositories {
|
||||
maven {
|
||||
|
@ -97,10 +120,15 @@ class LomPlugin @Inject constructor(private val softwareComponentFactory: Softwa
|
|||
mavenLocal()
|
||||
}
|
||||
|
||||
// Register dev configuration and add "dev" classifier to unremapped jars
|
||||
configurations.create("dev")
|
||||
// Mark normal jars as -dev
|
||||
tasks.jar.archiveClassifier.set("dev")
|
||||
|
||||
// Used for referencing the unremapped jars of other projects
|
||||
artifacts.add(configurations.create("dev").name, tasks.jar.archiveFile.get().asFile) {
|
||||
type = "jar"
|
||||
builtBy(tasks.jar)
|
||||
}
|
||||
|
||||
// configure the shadow task to not shadow by default and output to builds/devlibs
|
||||
tasks.shadowJar {
|
||||
val inputTask: Jar = tasks.findByName("injectCompiledConfig") as Jar? ?: tasks.jar // get injectCompiledConfig task if present (-> LibJF) or use normal jar task
|
||||
|
@ -111,13 +139,6 @@ class LomPlugin @Inject constructor(private val softwareComponentFactory: Softwa
|
|||
destinationDirectory.set(devlibs)
|
||||
}
|
||||
|
||||
// this is here for some reason
|
||||
// TODO wtf does this do?
|
||||
artifacts.add("dev", tasks.jar.archiveFile.get().asFile) {
|
||||
type = "jar"
|
||||
builtBy(tasks.jar)
|
||||
}
|
||||
|
||||
// generate sources jar to publish for better debugging with dependents
|
||||
java {
|
||||
withSourcesJar()
|
||||
|
@ -138,22 +159,6 @@ class LomPlugin @Inject constructor(private val softwareComponentFactory: Softwa
|
|||
}
|
||||
tasks.assemble.dependsOn(remapMavenJar)
|
||||
|
||||
// generate jar from testmod source set
|
||||
val testmodJar by tasks.registering(Jar::class) {
|
||||
from(sourceSets.testmod.output)
|
||||
destinationDirectory.set(devlibs)
|
||||
archiveClassifier.set("testmod")
|
||||
}
|
||||
|
||||
// remap configuration for outputting usable testmod jar
|
||||
val remapTestmodJar by tasks.registering(RemapJarTask::class) { //TODO include deps
|
||||
dependsOn(testmodJar)
|
||||
inputFile.set(testmodJar.archiveFile.get())
|
||||
archiveClassifier.set("testmod")
|
||||
addNestedDependencies.set(false)
|
||||
}
|
||||
tasks.assemble.dependsOn(remapTestmodJar)
|
||||
|
||||
// configure remapJar to use the output of shadow
|
||||
tasks.remapJar {
|
||||
dependsOn(tasks.shadowJar.get())
|
||||
|
@ -180,6 +185,31 @@ class LomPlugin @Inject constructor(private val softwareComponentFactory: Softwa
|
|||
tasks.publish.dependsOn(tasks.build)
|
||||
tasks.deployDebug.dependsOn(tasks.publish)
|
||||
|
||||
// create testmodInclude configuration
|
||||
val testmodIncludeConfiguration = configurations.create("testmodInclude")
|
||||
|
||||
if (hasTestmod) {
|
||||
// generate jar from testmod source set
|
||||
val testmodJar by tasks.registering(Jar::class) {
|
||||
from(sourceSets.testmod.output)
|
||||
destinationDirectory.set(devlibs)
|
||||
archiveClassifier.set("testmod")
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
// remap configuration for outputting usable testmod jar
|
||||
val remapTestmodJar by tasks.registering(RemapJarTask::class) {
|
||||
dependsOn(testmodJar)
|
||||
inputFile.set(testmodJar.archiveFile.get())
|
||||
archiveClassifier.set("testmod")
|
||||
// add nested jars from testmodInclude
|
||||
addNestedDependencies.set(true)
|
||||
nestedJars.setFrom(*testmodIncludeConfiguration.files.toTypedArray())
|
||||
}
|
||||
tasks.assemble.dependsOn(remapTestmodJar)
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
// from fabric-example-mod, enforces modern java
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
|
@ -188,7 +218,6 @@ class LomPlugin @Inject constructor(private val softwareComponentFactory: Softwa
|
|||
}
|
||||
|
||||
// otherwise we can't easily overwrite the artifacts to publish while keeping dependency metadata
|
||||
//TODO find a better solution to this (custom component?)
|
||||
tasks.withType<GenerateModuleMetadata> {
|
||||
enabled = false
|
||||
}
|
||||
|
@ -205,4 +234,4 @@ class LomPlugin @Inject constructor(private val softwareComponentFactory: Softwa
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue