Skip to content

Commit

Permalink
Loom and Legacy-Looming 1.5 - Fix Pom generation and enable paralleli…
Browse files Browse the repository at this point in the history
…zation back (#160)

* Loom and Legacy-Looming 1.5

* Enable org.gradle.parallel

* Update editorconfig

* fix pom generation

* fix maven artifact name again

* Fix concurrency errors on pom generation

* Fix concurrency errors because of shared artifactId

* Possible workaround concurrency issues

* Set back artifactId to normal
  • Loading branch information
thecatcore authored Feb 22, 2024
1 parent d86ea8c commit c140ada
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 18 deletions.
9 changes: 4 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ indent_style = tab

[*.java]
indent_style = tab
ij_continuation_indent_size = 8
ij_java_imports_layout = $*,|,java.**,|,javax.**,|,*,|,net.minecraft.**,|,net.fabricmc.**,|,net.legacyfabric.**
ij_java_class_count_to_use_import_on_demand = 999

[*.json]
indent_style = space
indent_size = 2

[*.yml]
indent_style = space
indent_size = 2

[*.properties]
indent_style = space
indent_size = 2

[.editorconfig]
indent_style = space
indent_size = 4
indent_size = 4
80 changes: 67 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ plugins {
id "eclipse"
id "idea"
id "maven-publish"
id "fabric-loom" version "1.3.9" apply false
id "legacy-looming" version "1.3.75" apply false
id "fabric-loom" version "1.5.4" apply false
id "legacy-looming" version "1.5.3" apply false
id "com.diffplug.spotless" version "6.20.0"
id "org.ajoberstar.grgit" version "3.1.1"
id "me.modmuss50.mod-publish-plugin" version "0.4.5"
Expand All @@ -28,9 +28,11 @@ def supportedRanges = [
// ["1.8", "1.8.9", false] // third parameter is whether or not to include snapshots in the range.
]


import groovy.json.JsonSlurper
import net.fabricmc.loom.task.RemapJarTask
//import org.apache.commons.codec.digest.DigestUtils
import net.legacyfabric.VersionHelper
import org.apache.commons.codec.digest.DigestUtils

static def getMCVersion(Project project) {
def projectFullName = project.name
Expand All @@ -49,7 +51,7 @@ static def getProjectSimpleName(Project project) {

if (!projectFullName.contains("_")) return projectFullName

return projectFullName.split("_")[0]
return projectFullName.split("_")[0].trim()
}

def getProjectMavenName(projectLike) {
Expand All @@ -73,7 +75,7 @@ def getProjectMavenName(projectLike) {
}
}

return simpleName
return simpleName.trim()
}


Expand Down Expand Up @@ -131,8 +133,9 @@ def getSubprojectVersion(Project project) {
if (latestCommits.isEmpty()) {
return version + "+uncommited"
} else {
return version + "+" + latestCommits.get(0).id.substring(0, 8) //+
// DigestUtils.sha256Hex("${project.name}").substring(0, 2)
return version + "+" + latestCommits.get(0).id.substring(0, 8) +
DigestUtils.sha256Hex("${project.name}").substring(0, 2) +
DigestUtils.sha256Hex("${mcVersion}").substring(0, 2)
}
}

Expand Down Expand Up @@ -214,12 +217,6 @@ def moduleDependencies(Project project, List<String> projectNames) {
project.publishing {
publications {
mavenJava(MavenPublication) {
if (getProjectSimpleName(project) == "legacyfabric-api") {
artifactId = "legacy-fabric-api"
} else {
artifactId = getProjectMavenName(project)
}

pom.withXml {
def depsNode = asNode().appendNode("dependencies")
deps.each {
Expand Down Expand Up @@ -283,6 +280,10 @@ allprojects {
def hasTest = it.file("src/testmod").exists()

loom {
mixin {
useLegacyMixinAp = true
}

runs {
"testModClient$mcVersion" {
client()
Expand Down Expand Up @@ -431,6 +432,40 @@ task javadocJar(type: Jar) {

build.dependsOn javadocJar

def addPomMetadataInformation(Project project, MavenPom pom) {
def modJsonFile = project.file("src/main/resources/fabric.mod.json")

if (!modJsonFile.exists()) {
modJsonFile = project.file("src/client/resources/fabric.mod.json")
}

def modJson = new JsonSlurper().parse(modJsonFile)
pom.name = modJson.name
pom.url = "https://github.com/Legacy-Fabric/fabric/tree/HEAD/${project.rootDir.relativePath(project.projectDir)}"
pom.description = modJson.description
pom.licenses {
license {
name = "Apache-2.0"
url = "https://github.com/Legacy-Fabric/fabric/blob/HEAD/LICENSE"
}
}
pom.developers {
developer {
name = "Legacy Fabric"
url = "https://legacyfabric.net/"
}
}
pom.scm {
connection = "scm:git:https://github.com/Legacy-Fabric/fabric.git"
url = "https://github.com/Legacy-Fabric/fabric"
developerConnection = "scm:git:git@github.com:Legacy-Fabric/fabric.git"
}
pom.issueManagement {
system = "GitHub"
url = "https://github.com/Legacy-Fabric/fabric/issues"
}
}

subprojects {
base {
archivesName = getProjectMavenName(it)
Expand All @@ -447,6 +482,16 @@ subprojects {
publishing {
publications {
mavenJava(MavenPublication) {
if (getProjectSimpleName(project) == "legacyfabric-api") {
artifactId = "legacy-fabric-api"
} else {
artifactId = getProjectMavenName(project)
}

pom {
addPomMetadataInformation(project, pom)
}

artifact(remapJar) {
builtBy remapJar
}
Expand Down Expand Up @@ -483,6 +528,15 @@ publishing {
publications {}
}

subprojects {
project.tasks.withType(PublishToMavenLocal).each {
it.outputs.file("$rootProject.projectDir/temp")
}
project.tasks.withType(PublishToMavenRepository).each {
it.outputs.file("$rootProject.projectDir/temp")
}
}

subprojects.each { if (it.file("src/main").exists()) remapJar.dependsOn("${it.path}:remapJar") }

sourceSets {
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ repositories {
name = "Fabric"
url = "https://maven.fabricmc.net/"
}
mavenCentral()
}

dependencies {
implementation("net.fabricmc:fabric-loader:0.15.6")
implementation("commons-codec:commons-codec:1.16.1")
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.parallel=true

base_version = 1.9.2
loader_version = 0.14.22
Expand Down

0 comments on commit c140ada

Please sign in to comment.