diff --git a/build.gradle b/build.gradle index 6185d0877..fb3b223ec 100644 --- a/build.gradle +++ b/build.gradle @@ -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 } diff --git a/fabric-api-bom/build.gradle b/fabric-api-bom/build.gradle new file mode 100644 index 000000000..2a48fd7f8 --- /dev/null +++ b/fabric-api-bom/build.gradle @@ -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)) + } + } +} diff --git a/fabric-api-catalog/build.gradle b/fabric-api-catalog/build.gradle new file mode 100644 index 000000000..b6e2d1f75 --- /dev/null +++ b/fabric-api-catalog/build.gradle @@ -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}") + } + } + } +} diff --git a/gradle/module-validation.gradle b/gradle/module-validation.gradle index 4a1012e16..5f4835596 100644 --- a/gradle/module-validation.gradle +++ b/gradle/module-validation.gradle @@ -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 } diff --git a/settings.gradle b/settings.gradle index 2db408cbe..5c6d803a8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -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'