Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,48 @@ abstract class PublishingHelperExtension
@Inject
constructor(objectFactory: ObjectFactory, project: Project) {
// the following are only relevant on the root project
val asfProjectName = objectFactory.property<String>().convention(project.name)

/**
* Lowercase ASF project ID, as present in keys in the JSON docs describing the projects (for
* example in `https://whimsy.apache.org/public/public_ldap_projects.json`).
*/
val asfProjectId = objectFactory.property<String>().convention(project.name)

/** Used to override the full project name, for example `Apache Polaris`. */
val overrideName = objectFactory.property<String>()
/** Used to override the project description as it appears in published Maven poms. */
val overrideDescription = objectFactory.property<String>()
/** Used to override the project URL as it appears in published Maven poms. */
val overrideProjectUrl = objectFactory.property<String>()
/**
* Used to override the name of the GitHub repo in the apache organization. Defaults to the
* project ID.
*/
val githubRepositoryName = objectFactory.property<String>()
/**
* Used to override the project's SCM as it appears in published Maven poms. Default is derived
* from `githubRepoName`.
*/
val overrideScm = objectFactory.property<String>()
/** Used to override the project's issue management URL as it appears in published Maven poms. */
val overrideIssueManagement = objectFactory.property<String>()
/** Prefix for the tag published for non-SNAPSHOT versions in the Maven poms. */
val overrideTagPrefix = objectFactory.property<String>()

/** The published distributables, including the source tarball, base file name. */
val baseName =
objectFactory
.property<String>()
.convention(project.provider { "apache-${asfProjectName.get()}-${project.version}" })
.convention(project.provider { "apache-${asfProjectId.get()}-${project.version}" })

val distributionDir =
objectFactory.directoryProperty().convention(project.layout.buildDirectory.dir("distributions"))
val sourceTarball =
objectFactory
.fileProperty()
.convention(project.provider { distributionDir.get().file("${baseName.get()}.tar.gz") })

/** List of mailing-lists. */
val mailingLists = objectFactory.listProperty(String::class.java).convention(emptyList())

fun distributionFile(ext: String): File =
Expand Down
35 changes: 25 additions & 10 deletions build-logic/src/main/kotlin/publishing/configurePom.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import groovy.util.Node
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.artifacts.component.ModuleComponentSelector
import org.gradle.api.provider.Provider
import org.gradle.api.publish.maven.MavenPom
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.internal.extensions.stdlib.capitalized
Expand Down Expand Up @@ -73,7 +74,7 @@ internal fun configurePom(project: Project, mavenPublication: MavenPublication,

task.doFirst {
mavenPom.run {
val asfName = e.asfProjectName.get()
val asfName = e.asfProjectId.get()
val projectPeople = fetchProjectPeople(asfName)

organization {
Expand All @@ -98,21 +99,35 @@ internal fun configurePom(project: Project, mavenPublication: MavenPublication,
}
}

val githubRepoName: Provider<String> = e.githubRepositoryName.orElse(asfName)
val codeRepo: Provider<String> =
e.overrideScm.orElse(
githubRepoName
.map { r -> "https://github.com/apache/$r" }
.orElse(projectPeople.repository)
)

scm {
val codeRepo: String = projectPeople.repository
connection.set("scm:git:$codeRepo")
developerConnection.set("scm:git:$codeRepo")
url.set("$codeRepo/tree/main")
val codeRepoString: String = codeRepo.get()
connection.set("scm:git:$codeRepoString")
developerConnection.set("scm:git:$codeRepoString")
url.set("$codeRepoString/tree/main")
val version = project.version.toString()
if (!version.endsWith("-SNAPSHOT")) {
tag.set("apache-polaris-$version")
val tagPrefix: String =
e.overrideTagPrefix.orElse("apache-${projectPeople.apacheId}").get()
tag.set("$tagPrefix-$version")
}
}
issueManagement { url.set(projectPeople.bugDatabase) }
issueManagement {
val issuesUrl: Provider<String> =
codeRepo.map { r -> "$r/issues" }.orElse(projectPeople.bugDatabase)
url.set(e.overrideIssueManagement.orElse(issuesUrl))
}

name.set(e.overrideName.orElse(projectPeople.name))
name.set(e.overrideName.orElse("Apache ${projectPeople.name}"))
description.set(e.overrideDescription.orElse(projectPeople.description))
url.set(projectPeople.website)
url.set(e.overrideProjectUrl.orElse(projectPeople.website))
inceptionYear.set(projectPeople.inceptionYear.toString())

developers {
Expand All @@ -127,7 +142,7 @@ internal fun configurePom(project: Project, mavenPublication: MavenPublication,
}
}

addContributorsToPom(mavenPom, asfName, "Apache ${projectPeople.name}")
addContributorsToPom(mavenPom, githubRepoName.get(), "Apache ${projectPeople.name}")
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions build-logic/src/main/kotlin/publishing/rootProject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ internal fun configureOnRootProject(project: Project) =

doFirst {
val e = project.extensions.getByType(PublishingHelperExtension::class.java)
val asfName = e.asfProjectName.get()
val asfName = e.asfProjectId.get()

val gitInfo = MemoizedGitInfo.gitInfo(rootProject)
val gitCommitId = gitInfo["Apache-Polaris-Build-Git-Head"]
Expand Down Expand Up @@ -132,7 +132,8 @@ internal fun configureOnRootProject(project: Project) =
"NO STAGING REPOSITORY (no build service) !!"
}

val asfProjectName = "Apache Polaris"
val asfProjectName =
e.overrideName.orElse(project.provider { "Apache ${fetchAsfProjectName(asfName)}" }).get()

val versionNoRc = version.toString().replace("-rc-?[0-9]+".toRegex(), "")

Expand Down
24 changes: 21 additions & 3 deletions build-logic/src/main/kotlin/publishing/util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ internal fun <T : Any> parseJson(url: String): T {
}
}

// TODO: this function doesn't work because name attribute doesn't exist on
// public_ldap_projects.json
/** Retrieves the project name, for example `Polaris` using the lower-case project ID. */
internal fun fetchAsfProjectName(apacheId: String): String {
val projectsAll: Map<String, Map<String, Any>> =
parseJson("https://whimsy.apache.org/public/public_ldap_projects.json")
Expand All @@ -90,7 +89,25 @@ internal fun fetchAsfProjectName(apacheId: String): String {
?: throw IllegalArgumentException(
"No project '$apacheId' found in https://whimsy.apache.org/public/public_ldap_projects.json"
)
return project["name"] as String
val isPodlingCurrent = project.containsKey("podling") && project["podling"] == "current"
if (isPodlingCurrent) {
val podlingsAll: Map<String, Map<String, Any>> =
parseJson("https://whimsy.apache.org/public/public_podlings.json")
val podlings = unsafeCast<Map<String, Map<String, Any>>>(podlingsAll["podling"])
val podling =
podlings[apacheId]
?: throw IllegalArgumentException(
"No podling '$apacheId' found in https://whimsy.apache.org/public/public_podlings.json"
)
return podling["name"] as String
} else {
// top-level-project
val committeesAll: Map<String, Map<String, Any>> =
parseJson("https://whimsy.apache.org/public/committee-info.json")
val committees = unsafeCast<Map<String, Map<String, Any>>>(committeesAll["committees"])
val committee = unsafeCast<Map<String, Any>>(committees[apacheId])
return committee["display_name"] as String
}
}

internal fun fetchProjectPeople(apacheId: String): ProjectPeople {
Expand Down Expand Up @@ -146,6 +163,7 @@ internal fun fetchProjectPeople(apacheId: String): ProjectPeople {
val mentors = unsafeCast(podling["mentors"]) as List<String>
mentors.forEach { member -> peopleProjectRoles[member]!!.add("Mentor") }
} else {
// top-level-project
val tlpPrj: Map<String, Any> =
parseJson("https://projects.apache.org/json/projects/$apacheId.json")
website = tlpPrj["homepage"] as String
Expand Down