Skip to content

Commit

Permalink
Add mojmap artifact variants of API.
Browse files Browse the repository at this point in the history
  • Loading branch information
LambdAurora committed Nov 9, 2024
1 parent 36f81c9 commit 2bd2cd6
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
14 changes: 14 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ tasks.generateFmj.configure {
}
}

val mojmap by sourceSets.creating {}

java {
registerFeature("mojmap") {
usingSourceSet(mojmap)
withSourcesJar()

afterEvaluate {
configurations["mojmapApiElements"].extendsFrom(configurations["apiElements"])
configurations["mojmapRuntimeElements"].extendsFrom(configurations["runtimeElements"])
}
}
}

// Configure the maven publication.
publishing {
publications {
Expand Down
60 changes: 60 additions & 0 deletions api/moj_xplat/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import lambdynamiclights.Constants
import net.fabricmc.loom.LoomGradleExtension
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace
import net.fabricmc.loom.task.RemapJarTask
import net.fabricmc.loom.task.RemapSourcesJarTask

plugins {
id("lambdynamiclights-common")
}

base.archivesName.set(Constants.NAME + "-api-mojmap")

dependencies {
mappings(loom.officialMojangMappings())
}

val apiProject = project(":api")

tasks.remapJar {
val remapJar = apiProject.tasks.named("remapJar", RemapJarTask::class)
dependsOn(remapJar)

classpath.setFrom((loom as LoomGradleExtension).getMinecraftJarsCollection(MappingsNamespace.INTERMEDIARY))
inputFile.convention(remapJar.flatMap { it.archiveFile })
sourceNamespace = "intermediary"
targetNamespace = "named"
}

// Add the remapped JAR artifact
apiProject.configurations["mojmapApiElements"].artifacts.removeIf{
true
}
apiProject.artifacts.add("mojmapApiElements", tasks.remapJar.map { it.archiveFile }) {
classifier = "mojmap"
}
apiProject.configurations["mojmapRuntimeElements"].artifacts.removeIf{
true
}
apiProject.artifacts.add("mojmapRuntimeElements", tasks.remapJar.map { it.archiveFile }) {
classifier = "mojmap"
}

val remapMojmapSourcesTask = tasks.register("remapMojmapSourcesJar", RemapSourcesJarTask::class) {
val remapJar = apiProject.tasks.named("remapSourcesJar", RemapSourcesJarTask::class)
dependsOn(remapJar)

classpath.setFrom((loom as LoomGradleExtension).getMinecraftJarsCollection(MappingsNamespace.INTERMEDIARY))
inputFile.convention(remapJar.flatMap { it.archiveFile })
archiveClassifier = "moj"
sourceNamespace = "intermediary"
targetNamespace = "named"
}

// Add the remapped sources artifact
apiProject.configurations["mojmapSourcesElements"].artifacts.removeIf {
true
}
apiProject.artifacts.add("mojmapSourcesElements", remapMojmapSourcesTask.map { it.archiveFile }) {
classifier = "mojmap-sources"
}
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ pluginManagement {
}

includeBuild("build_logic")
include("api")
include("api", "api:moj_xplat")

0 comments on commit 2bd2cd6

Please sign in to comment.