Skip to content

Commit

Permalink
Merge branch 'feature/registry-sync-v2/main' into feature/registry-sy…
Browse files Browse the repository at this point in the history
…nc-v2/api
  • Loading branch information
thecatcore authored Dec 7, 2024
2 parents 7f70796 + b3da594 commit 3883ea7
Show file tree
Hide file tree
Showing 160 changed files with 312 additions and 8,352 deletions.
103 changes: 50 additions & 53 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id "eclipse"
id "idea"
id "maven-publish"
id "fabric-loom" version "1.8.11" apply false
id "fabric-loom" version "1.8.13" apply false
id "legacy-looming" version "1.8.2" apply false
id "com.diffplug.spotless" version "6.20.0"
id "org.ajoberstar.grgit" version "5.2.2"
Expand Down Expand Up @@ -35,27 +35,31 @@ import net.fabricmc.loom.task.RemapJarTask
import net.legacyfabric.VersionHelper
import org.apache.commons.codec.digest.DigestUtils

static def getMCVersion(Project project) {
def projectFullName = project.name
static def parseProjectName(String name, Project project) {
def parts = name.split("_")

if (!projectFullName.contains("_")) return "1.8.9"
if (parts.length < 2) parts = [*parts, "1.8.9"]

def mcVersion = projectFullName.split("_")[1]
def (moduleName, mcVersion) = parts

if (mcVersion == "common") return "1.8.9"
def isCommon = mcVersion == "common"

return mcVersion
}
def mavenName = moduleName.trim()

static def getProjectSimpleName(Project project) {
def projectFullName = project.name
if (isCommon) {
mcVersion = "1.8.9"

if (!projectFullName.contains("_")) return projectFullName
if (project != null && project.hasProperty("artifactSuffix")) {
mavenName += project["artifactSuffix"]
} else {
mavenName += "-common"
}
}

return projectFullName.split("_")[0].trim()
return [moduleName.trim(), mcVersion, isCommon, mavenName.trim()]
}

def getProjectMavenName(projectLike) {
def projectInfoFromName(projectLike) {
Project project
if (!(projectLike instanceof Project)) {
if (projectLike instanceof BasePluginExtension) {
Expand All @@ -66,21 +70,9 @@ def getProjectMavenName(projectLike) {
}
else project = projectLike

def simpleName = getProjectSimpleName(project)

if (project.name.endsWith("_common")) {
if (project.hasProperty("artifactSuffix")) {
simpleName += project["artifactSuffix"]
} else {
simpleName += "-common"
}
}

return simpleName.trim()
return parseProjectName(project.name, project)
}



static def getMCRange(Project project) {
def predicates = []

Expand Down Expand Up @@ -114,18 +106,16 @@ static def getMCRange(Project project) {
def getSubprojectVersion(Project project) {
def version

def nameParts = project.name.split("_")
def projectName = nameParts[0]
def mcVersion = nameParts[1]
def (moduleName, mcVersion, isCommon) = projectInfoFromName(project)

if (projectName == "legacyfabric-api") version = rootProject.version
else version = rootProject[projectName + ".version"]
if (moduleName == "legacyfabric-api") version = rootProject.version
else version = rootProject[moduleName + ".version"]

if (mcVersion != "common") {
if (!isCommon) {
version = version + "+" + mcVersion
}

if (projectName == "legacyfabric-api") return version
if (moduleName == "legacyfabric-api") return version

if (grgit == null) {
return version + "+nogit"
Expand Down Expand Up @@ -158,7 +148,7 @@ def static setupRepositories(RepositoryHandler repositories) {
def ENV = System.getenv()
if (ENV.MAVEN_PUBLISH_CREDENTIALS) {
repositories.maven {
url "https://maven.legacyfabric.net/"
url "https://repo.legacyfabric.net/legacyfabric/"
credentials {
username ENV.MAVEN_PUBLISH_CREDENTIALS.split(":")[0]
password ENV.MAVEN_PUBLISH_CREDENTIALS.split(":")[1]
Expand All @@ -173,22 +163,22 @@ def static setupRepositories(RepositoryHandler repositories) {
def moduleDependencies(Project project, List<String> projectNames) {
def depNames = []

def projectMCVersion = VersionHelper.parseVersion(getMCVersion(project))
def (moduleName, mcVersion, isCommon) = projectInfoFromName(project)

def isCommon = project.name.endsWith("_common")
def projectMCVersion = VersionHelper.parseVersion(mcVersion)

rootProject.subprojects {
def subProjectName = getProjectSimpleName(it)
def (subModuleName) = projectInfoFromName(it)

if (projectNames.contains(subProjectName)) {
if (projectNames.contains(subModuleName)) {
def predicate = VersionHelper.parsePredicate(getMCRange(it))

if (predicate.test(projectMCVersion)) depNames.add(it.name)
}
}

if (!isCommon) {
def commonProject = findProject(":${getProjectSimpleName(project)}_common")
def commonProject = findProject(":${moduleName}_common")

if (commonProject != null) {
depNames.add(0, commonProject.name)
Expand All @@ -210,7 +200,7 @@ def moduleDependencies(Project project, List<String> projectNames) {
}
}

if (getProjectSimpleName(project) != "legacy-fabric-logger-api-v1") {
if (moduleName != "legacy-fabric-logger-api-v1") {
deps.add(project.dependencies.project(path: ":legacy-fabric-logger-api-v1_common", configuration: "namedElements"))
}

Expand All @@ -221,9 +211,11 @@ def moduleDependencies(Project project, List<String> projectNames) {
pom.withXml {
def depsNode = asNode().appendNode("dependencies")
deps.each {
def (_, _1, _2, mavenName) = projectInfoFromName(it)

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

Expand Down Expand Up @@ -281,8 +273,7 @@ allprojects {
setVersion(getSubprojectVersion(it))
}

def mcVersion = getMCVersion(it)
String projectName = getProjectSimpleName(it)
def (moduleName, mcVersion, _) = projectInfoFromName(it)
def hasTest = it.file("src/testmod").exists()

loom {
Expand All @@ -297,7 +288,7 @@ allprojects {
runs {
"testModClient$mcVersion" {
client()
ideConfigGenerated projectName == "legacyfabric-api"
ideConfigGenerated moduleName == "legacyfabric-api"
name = "$mcVersion Testmod Client"
source sourceSets.testmod

Expand All @@ -308,7 +299,7 @@ allprojects {

"testModServer$mcVersion" {
server()
ideConfigGenerated projectName == "legacyfabric-api"
ideConfigGenerated moduleName == "legacyfabric-api"
name = "$mcVersion Testmod Server"
source sourceSets.testmod
}
Expand Down Expand Up @@ -487,25 +478,27 @@ def addPomMetadataInformation(Project project, MavenPom pom) {
}

subprojects {
def (moduleName, _, _1, mavenName) = projectInfoFromName(project)

base {
archivesName = getProjectMavenName(it)
archivesName = mavenName
}

dependencies {
testmodImplementation sourceSets.main.output

if (getProjectSimpleName(project) != "legacy-fabric-logger-api-v1") {
if (moduleName != "legacy-fabric-logger-api-v1") {
api project(path: ":legacy-fabric-logger-api-v1_common", configuration: "namedElements")
}
}

publishing {
publications {
mavenJava(MavenPublication) {
if (getProjectSimpleName(project) == "legacyfabric-api") {
if (moduleName == "legacyfabric-api") {
artifactId = "legacy-fabric-api"
} else {
artifactId = getProjectMavenName(project)
artifactId = mavenName
}

pom {
Expand All @@ -527,9 +520,9 @@ subprojects {

javadoc.enabled = false

def scriptPath = rootProject.file("${getProjectSimpleName(project)}/common.gradle")
def scriptPath = rootProject.file("${moduleName}/common.gradle")
if (scriptPath.exists()) {
apply from: rootProject.file("${getProjectSimpleName(project)}/common.gradle")
apply from: rootProject.file("${moduleName}/common.gradle")
}

afterEvaluate {
Expand Down Expand Up @@ -566,7 +559,9 @@ sourceSets {
dependencies {
afterEvaluate {
subprojects.each {
if (getProjectSimpleName(it) == "legacyfabric-api") return
def (moduleName) = projectInfoFromName(it)

if (moduleName == "legacyfabric-api") return

if (it.file("src/main").exists()) api project(path: "${it.path}", configuration: "namedElements")
if (it.file("src/testmod").exists()) testmodImplementation project("${it.path}").sourceSets.testmod.output
Expand All @@ -577,7 +572,9 @@ dependencies {
remapJar {
afterEvaluate {
subprojects.each {
if (getProjectSimpleName(it) == "legacyfabric-api") return
def (moduleName) = projectInfoFromName(it)

if (moduleName == "legacyfabric-api") return
// Include the signed or none signed jar from the sub project.
if (it.file("src/main").exists()) nestedJars.from project("${it.path}:").tasks.getByName("remapJar")
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ yarn_mappings_build = 530
## Module versions
legacy-fabric-api-base.version = 1.1.0
legacy-fabric-command-api-v1.version = 1.0.1
legacy-fabric-command-api-v2.version = 1.0.2
legacy-fabric-command-api-v2.version = 1.1.0
legacy-fabric-crash-report-info-v1.version = 1.0.0
legacy-fabric-entity-events-v1.version = 1.0.0
legacy-fabric-gamerule-api-v1.version = 1.0.0
Expand All @@ -17,7 +17,7 @@ legacy-fabric-keybindings-api-v1.version = 1.1.1
legacy-fabric-lifecycle-events-v1.version = 1.1.0
legacy-fabric-logger-api-v1.version = 1.0.4
legacy-fabric-networking-api-v1.version = 2.0.2
legacy-fabric-permissions-api-v1.version = 1.1.0
legacy-fabric-permissions-api-v1.version = 1.1.1
legacy-fabric-registry-sync-api-v1.version = 2.2.0
legacy-fabric-registry-sync-api-v2.version = 1.0.0
legacy-fabric-rendering-api-v1.version = 1.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public Text getUsage(PermissibleCommandSource src) {

if (usage.asUnformattedString().trim().length() > 0) {
builder.add(" ");
builder.add(usage);
builder.add(usage.asUnformattedString());
}

builder.add("]");
Expand Down
Loading

0 comments on commit 3883ea7

Please sign in to comment.