Add metadata information to POMs (#3074)

* Add metadata information to POMs

* Add name, description, url and issue management

Also update the license name and an url to the fabric website
Pulls name and description from the fabric.mod.json

* Fix imports and make git optional

* Remove commit from maven metadata
This commit is contained in:
Roman / Linnea Gräf 2023-05-30 13:52:53 +02:00 committed by GitHub
parent 4014940769
commit 7f4bf1fd8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,6 +24,8 @@ def signingEnabled = ENV.SIGNING_SERVER
version = project.version + "+" + (ENV.GITHUB_RUN_NUMBER ? "" : "local-") + getBranch()
logger.lifecycle("Building Fabric: " + version)
import groovy.json.JsonSlurper
import org.apache.commons.codec.digest.DigestUtils
def getSubprojectVersion(project) {
@ -509,6 +511,37 @@ task runProductionAutoTestServer(type: JavaExec, dependsOn: [remapJar, remapTest
}
}
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/FabricMC/fabric/tree/HEAD/${project.rootDir.relativePath(project.projectDir)}"
pom.description = modJson.description
pom.licenses {
license {
name = "Apache-2.0"
url = "https://github.com/FabricMC/fabric/blob/HEAD/LICENSE"
}
}
pom.developers {
developer {
name = "FabricMC"
url = "https://fabricmc.net/"
}
}
pom.scm {
connection = "scm:git:https://github.com/FabricMC/fabric.git"
url = "https://github.com/FabricMC/fabric"
developerConnection = "scm:git:git@github.com:FabricMC/fabric.git"
}
pom.issueManagement {
system = "GitHub"
url = "https://github.com/FabricMC/fabric/issues"
}
}
subprojects {
if (it.name == "deprecated") return
@ -533,6 +566,9 @@ subprojects {
publishing {
publications {
mavenJava(MavenPublication) {
pom {
addPomMetadataInformation(project, pom)
}
artifact(signingEnabled ? signRemapJar.output : remapJar) {
builtBy(signingEnabled ? signRemapJar : remapJar)
}
@ -564,6 +600,10 @@ publishing {
artifact javadocJar
artifact remapTestmodJar
pom {
addPomMetadataInformation(rootProject, pom)
}
pom.withXml {
def depsNode = asNode().appendNode("dependencies")
subprojects.each {