Skip to content

Commit

Permalink
Infer module dependencies from MCVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed Feb 8, 2024
1 parent 9a3b3aa commit 728f2ea
Showing 1 changed file with 41 additions and 25 deletions.
66 changes: 41 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,32 @@ def getProjectMavenName(project) {
return simpleName
}



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

if (project.hasProperty("minVersionIncluded")) {
predicates.add(">=${VersionHelper.parseVersion(project["minVersionIncluded"]).friendlyString}")
}

if (project.hasProperty("minVersionExcluded")) {
predicates.add(">${VersionHelper.parseVersion(project["minVersionExcluded"]).friendlyString}")
}

if (project.hasProperty("maxVersionIncluded")) {
predicates.add("<=${VersionHelper.parseVersion(project["maxVersionIncluded"]).friendlyString}")
}

if (project.hasProperty("maxVersionExcluded")) {
predicates.add("<${VersionHelper.parseVersion(project["maxVersionExcluded"]).friendlyString}")
}

if (predicates.isEmpty()) predicates.add("*")

return predicates.join(" ")
}

def getSubprojectVersion(Project project) {
def version

Expand Down Expand Up @@ -122,7 +148,21 @@ def static setupRepositories(RepositoryHandler repositories) {
}
}

def moduleDependencies(Project project, List<String> depNames) {
def moduleDependencies(Project project, List<String> projectNames) {
def depNames = []

def projectMCVersion = VersionHelper.parseVersion(getMCVersion(project))

rootProject.subprojects {
def subProjectName = getProjectSimpleName(it)

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

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

if (!project.name.endsWith("_common")) {
def commonProject = findProject(":${getProjectSimpleName(project)}_common")

Expand Down Expand Up @@ -173,30 +213,6 @@ def moduleDependencies(Project project, List<String> depNames) {
}
}

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

if (project.hasProperty("minVersionIncluded")) {
predicates.add(">=${VersionHelper.parseVersion(project["minVersionIncluded"]).friendlyString}")
}

if (project.hasProperty("minVersionExcluded")) {
predicates.add(">${VersionHelper.parseVersion(project["minVersionExcluded"]).friendlyString}")
}

if (project.hasProperty("maxVersionIncluded")) {
predicates.add("<=${VersionHelper.parseVersion(project["maxVersionIncluded"]).friendlyString}")
}

if (project.hasProperty("maxVersionExcluded")) {
predicates.add("<${VersionHelper.parseVersion(project["maxVersionExcluded"]).friendlyString}")
}

if (predicates.isEmpty()) predicates.add("*")

return predicates.join(" ")
}

allprojects {
group = "net.legacyfabric.legacy-fabric-api"

Expand Down

0 comments on commit 728f2ea

Please sign in to comment.