Skip to content

Commit

Permalink
Move deprecated modules, create own maven BOM for the deprecated modu…
Browse files Browse the repository at this point in the history
…les. (FabricMC#2171)

* Move deprecated modules to a sub directory.
Remove deprecated modules from the default maven pom
Create a new "fabric-api-legacy" bom with the deprecated modules.

* Fix main "fabric" project not beign a dep for the legacy bom.

* rename artifact to fabric-api-deprecated

* Spotless

* Use the latest version of spotless.
  • Loading branch information
modmuss50 authored May 1, 2022
1 parent 6da0939 commit df3654b
Show file tree
Hide file tree
Showing 78 changed files with 214 additions and 151 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
strategy:
matrix:
java: [17-jdk]
java: [17-jdk, 18-jdk]
runs-on: ubuntu-20.04
container:
image: eclipse-temurin:${{ matrix.java }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
build:
runs-on: ubuntu-20.04
container:
image: eclipse-temurin:17-jdk
image: eclipse-temurin:18-jdk
options: --user root
steps:
- run: apt update && apt install git -y && git --version
Expand Down
27 changes: 15 additions & 12 deletions HEADER
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
Copyright (c) 2016, 2017, 2018, 2019 FabricMC
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
84 changes: 48 additions & 36 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ plugins {
id "eclipse"
id "idea"
id "maven-publish"
id "fabric-loom" version "0.11.33" apply false
id "org.cadixdev.licenser" version "0.6.1"
id "fabric-loom" version "0.12.19" apply false
id "com.diffplug.spotless" version "6.5.1"
id "org.ajoberstar.grgit" version "3.1.0"
id "com.matthewprenger.cursegradle" version "1.4.0"
id "com.modrinth.minotaur" version "1.1.0"
Expand Down Expand Up @@ -89,19 +89,42 @@ def moduleDependencies(project, List<String> depNames) {
}

allprojects {
group = "net.fabricmc.fabric-api"

tasks.withType(GenerateModuleMetadata) {
enabled = false
}

if (signingEnabled) {
remoteSign {
requestUrl = ENV.SIGNING_SERVER
pgpAuthKey = ENV.SIGNING_PGP_KEY
jarAuthKey = ENV.SIGNING_JAR_KEY

afterEvaluate {
// PGP sign all maven publications.
sign publishing.publications.mavenJava
}
}
}

publishing {
setupRepositories(repositories)
}

if (it.name == "deprecated") return

apply plugin: "java-library"
apply plugin: "checkstyle"
apply plugin: "maven-publish"
apply plugin: "fabric-loom"
apply plugin: "org.cadixdev.licenser"
apply plugin: "com.diffplug.spotless"
apply plugin: "me.modmuss50.remotesign"

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
}

group = "net.fabricmc.fabric-api"

sourceSets {
testmod {
compileClasspath += main.compileClasspath
Expand Down Expand Up @@ -138,10 +161,6 @@ allprojects {
shareRemapCaches = true
}

repositories {
mavenLocal()
}

processResources {
inputs.property "version", project.version

Expand All @@ -150,9 +169,10 @@ allprojects {
}
}

license {
header rootProject.file("HEADER")
include "**/*.java"
spotless {
java {
licenseHeaderFile(rootProject.file("HEADER"))
}
}

java {
Expand All @@ -169,22 +189,9 @@ allprojects {
reproducibleFileOrder = true
}

tasks.withType(GenerateModuleMetadata) {
enabled = false
}

if (signingEnabled) {
remoteSign {
requestUrl = ENV.SIGNING_SERVER
pgpAuthKey = ENV.SIGNING_PGP_KEY
jarAuthKey = ENV.SIGNING_JAR_KEY

sign remapJar

afterEvaluate {
// PGP sign all maven publications.
sign publishing.publications.mavenJava
}
}
}

Expand Down Expand Up @@ -259,6 +266,8 @@ loom {
test.dependsOn runGametest

subprojects {
if (it.name == "deprecated") return

dependencies {
testmodImplementation sourceSets.main.output

Expand Down Expand Up @@ -286,8 +295,6 @@ subprojects {
}
}
}

setupRepositories(repositories)
}

// We manually handle the pom generation
Expand Down Expand Up @@ -332,6 +339,9 @@ publishing {
pom.withXml {
def depsNode = asNode().appendNode("dependencies")
subprojects.each {
// Dont depend on the deprecated modules in the main artifact.
if (it.path.startsWith(":deprecated")) return

def depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", it.group)
depNode.appendNode("artifactId", it.name)
Expand All @@ -341,8 +351,6 @@ publishing {
}
}
}

setupRepositories(repositories)
}

// Required until the deprecation is removed. Fabric API's main jar that is published to maven does not contain sub modules.
Expand All @@ -364,9 +372,11 @@ void setupRepositories(RepositoryHandler repositories) {
}
}

task licenseFormatAll
subprojects { p -> licenseFormatAll.dependsOn("${p.path}:licenseFormat") }
subprojects.each { remapJar.dependsOn("${it.path}:remapJar") }
subprojects.each {
if (it.name == "deprecated") return

remapJar.dependsOn("${it.path}:remapJar")
}

sourceSets {
testmod
Expand All @@ -381,20 +391,22 @@ def devOnlyModules = [
dependencies {
afterEvaluate {
subprojects.each {
api project(path: ":${it.name}", configuration: "namedElements")
if (it.name == "deprecated") return

api project(path: "${it.path}", configuration: "namedElements")

testmodImplementation project("${it.name}:").sourceSets.testmod.output
testmodImplementation project("${it.path}:").sourceSets.testmod.output
}
}
}

remapJar {
afterEvaluate {
subprojects.each {
if (it.name in devOnlyModules) return
if (it.name in devOnlyModules || it.name == "deprecated") return

// Include the signed or none signed jar from the sub project.
nestedJars.from project("${it.name}:").tasks.getByName(signingEnabled ? "signRemapJar" : "remapJar")
nestedJars.from project("${it.path}").tasks.getByName(signingEnabled ? "signRemapJar" : "remapJar")
}
}
}
Expand Down
38 changes: 38 additions & 0 deletions deprecated/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* This project generates a maven bill of materials (BOM) that includes the deprecated modules, alongside the main project.
*/

apply plugin: "maven-publish"

version = rootProject.version

publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'fabric-api-deprecated'

pom.withXml {
def depsNode = asNode().appendNode("dependencies")
allprojects.each {
if (it.name == "deprecated") return // Dont depend on yourself :)

// Depend on all of the deprecated projects
if (!it.path.startsWith(":deprecated")) return

def depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", it.group)
depNode.appendNode("artifactId", it.name)
depNode.appendNode("version", it.version)
depNode.appendNode("scope", "compile")
}

// Depend on the main project.
def depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", group)
depNode.appendNode("artifactId", "fabric-api")
depNode.appendNode("version", version)
depNode.appendNode("scope", "compile")
}
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion fabric-models-v0/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ moduleDependencies(project, [
])

dependencies {
testmodImplementation project(path: ':fabric-renderer-registries-v1', configuration: 'namedElements')
testmodImplementation project(path: ':fabric-rendering-v1', configuration: 'namedElements')
testmodImplementation project(path: ':fabric-resource-loader-v0', configuration: 'namedElements')
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
import net.fabricmc.fabric.api.client.rendereregistry.v1.LivingEntityFeatureRendererRegistrationCallback;
import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;

public class ModelTestModClient implements ClientModInitializer {
Expand Down
10 changes: 8 additions & 2 deletions gradle/module-validation.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import groovy.json.JsonSlurper
*/

subprojects {
if (it.name == "deprecated") return

// Create the task
task validateModules(type: ValidateModuleTask)
}
Expand Down Expand Up @@ -52,10 +54,14 @@ class ValidateModuleTask extends DefaultTask {
switch (moduleLifecycle) {
case "stable":
case "experimental":
break
case "deprecated":
break;
if (!project.path.startsWith(":deprecated")) {
throw new GradleException("Deprecated module ${project} must be in the deprecated sub directory.")
}
break
default:
throw new GradleException("Module ${project} has an invalid module lifecycle ${json.custom.get('fabric-api:module-lifecycle')}");
throw new GradleException("Module ${project} has an invalid module lifecycle ${json.custom.get('fabric-api:module-lifecycle')}")
}
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit df3654b

Please sign in to comment.