add fabric-api-bom and fabric-api-catalog (#3487)

* feat: add fabric-api-bom and fabric-api-catalog

* spotlessApply

* Apply suggestions from code review

Co-authored-by: Juuz <6596629+Juuxel@users.noreply.github.com>

---------

Co-authored-by: modmuss <modmuss50@gmail.com>
Co-authored-by: Juuz <6596629+Juuxel@users.noreply.github.com>
This commit is contained in:
Jason Penilla 2024-01-11 08:45:18 -07:00 committed by GitHub
parent b7e14635cf
commit 679aae3c9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 105 additions and 9 deletions

View file

@ -16,6 +16,11 @@ def ENV = System.getenv()
version = project.version + "+" + (ENV.GITHUB_RUN_NUMBER ? "" : "local-") + getBranch()
logger.lifecycle("Building Fabric: " + version)
def metaProjects = [
'deprecated',
'fabric-api-bom',
'fabric-api-catalog'
]
import net.fabricmc.loom.util.gradle.SourceSetHelper
import groovy.json.JsonSlurper
@ -132,7 +137,7 @@ allprojects {
setupRepositories(repositories)
}
if (it.name == "deprecated") {
if (metaProjects.contains(it.name)) {
return
}
@ -200,7 +205,7 @@ allprojects {
}
allprojects.each { p ->
if (project.name == "deprecated") {
if (metaProjects.contains(project.name)) {
return
}
@ -332,7 +337,7 @@ remapTestmodJar {
def testModJarTasks = []
subprojects {
if (it.name == "deprecated" || !(it.file("src/testmod").exists() || it.file("src/testmodClient").exists())) {
if (metaProjects.contains(it.name) || !(it.file("src/testmod").exists() || it.file("src/testmodClient").exists())) {
return
}
@ -374,7 +379,7 @@ javadoc {
}
allprojects.each {
if (it.name == "deprecated") {
if (metaProjects.contains(it.name)) {
return
}
@ -592,7 +597,7 @@ def addPomMetadataInformation(Project project, MavenPom pom) {
}
subprojects {
if (it.name == "deprecated") {
if (metaProjects.contains(it.name)) {
return
}
@ -705,7 +710,7 @@ void setupRepositories(RepositoryHandler repositories) {
}
subprojects.each {
if (it.name == "deprecated") {
if (metaProjects.contains(it.name)) {
return
}
@ -718,7 +723,7 @@ def devOnlyModules = ["fabric-gametest-api-v1",]
dependencies {
afterEvaluate {
subprojects.each {
if (it.name == "deprecated") {
if (metaProjects.contains(it.name)) {
return
}
@ -734,7 +739,7 @@ dependencies {
remapJar {
afterEvaluate {
subprojects.each {
if (it.name in devOnlyModules || it.name == "deprecated") {
if (it.name in devOnlyModules || metaProjects.contains(it.name)) {
return
}

View file

@ -0,0 +1,31 @@
plugins {
id 'java-platform'
}
version = rootProject.version
publishing.publications {
register('mavenJava', MavenPublication) {
from(components['javaPlatform'])
}
}
tasks.withType(GenerateModuleMetadata) {
// todo: RemoteSignJar fails when this is false (as set by parent build script)
enabled = true
}
dependencies {
constraints {
for (proj in rootProject.allprojects) {
if (proj == project) { // the bom itself
continue
}
if (proj.name == 'fabric-api-catalog') {
continue
}
api(project(proj.path))
}
}
}

View file

@ -0,0 +1,57 @@
plugins {
id 'version-catalog'
}
version = rootProject.version
publishing.publications {
register('mavenJava', MavenPublication) {
from components.versionCatalog
}
}
tasks.withType(GenerateModuleMetadata) {
// todo: RemoteSignJar fails when this is false (as set by parent build script)
enabled = true
}
// Avoid configuration ordering issues by creating the catalog entries during task execution time
tasks.register('configureCatalog') {
doFirst {
doConfigureCatalog()
}
}
tasks.named('generateCatalogAsToml') {
dependsOn('configureCatalog')
}
def doConfigureCatalog() {
for (proj in rootProject.allprojects) {
if (proj == project) { // the catalog itself
continue
}
String catalogName = proj.name
if (catalogName == 'fabric-api-base') {
catalogName = 'base'
} else if (catalogName == 'fabric-api-bom') {
catalogName = 'bom'
} else if (catalogName == 'deprecated') {
catalogName = 'deprecated-fabric-api'
} else if (catalogName == 'fabric-api') {
catalogName = 'fabric-api'
} else {
catalogName = catalogName.substring('fabric-'.length())
}
if (proj.parent != null && proj.parent.name == 'deprecated') {
catalogName = 'deprecated-' + catalogName
}
catalog {
versionCatalog {
library(catalogName, "net.fabricmc.fabric-api:${proj.name}:${proj.version}")
}
}
}
}

View file

@ -8,7 +8,7 @@ import groovy.json.JsonSlurper
*/
subprojects {
if (it.name == "deprecated") {
if (it.name == "deprecated" || it.name == "fabric-api-bom" || it.name == "fabric-api-catalog") {
return
}

View file

@ -11,6 +11,9 @@ pluginManagement {
rootProject.name = "fabric-api"
include 'fabric-api-bom'
include 'fabric-api-catalog'
include 'fabric-api-base'
include 'fabric-api-lookup-api-v1'