You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by jb...@apache.org on 2024/11/06 19:39:51 UTC
(polaris) branch main updated: Include *.kt files for spotless as well (#430)
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git
The following commit(s) were added to refs/heads/main by this push:
new 2ac3bb9f Include *.kt files for spotless as well (#430)
2ac3bb9f is described below
commit 2ac3bb9f0e892a8d536a1970fe37fb558adc09e7
Author: Robert Stupp <sn...@snazy.de>
AuthorDate: Wed Nov 6 20:39:47 2024 +0100
Include *.kt files for spotless as well (#430)
---
.../src/main/kotlin/LicenseFileValidation.kt | 18 +-
.../src/main/kotlin/polaris-root.gradle.kts | 2 +-
.../src/main/kotlin/publishing/MemoizedGitInfo.kt | 18 +-
.../kotlin/publishing/PublishingHelperExtension.kt | 36 +-
.../kotlin/publishing/PublishingHelperPlugin.kt | 31 +-
.../src/main/kotlin/publishing/configurePom.kt | 371 +++++++++++----------
.../src/main/kotlin/publishing/rootProject.kt | 179 +++++-----
.../src/main/kotlin/publishing/shadowPub.kt | 116 +++----
build-logic/src/main/kotlin/publishing/util.kt | 118 +++----
9 files changed, 470 insertions(+), 419 deletions(-)
diff --git a/build-logic/src/main/kotlin/LicenseFileValidation.kt b/build-logic/src/main/kotlin/LicenseFileValidation.kt
index c8d93828..c7457482 100644
--- a/build-logic/src/main/kotlin/LicenseFileValidation.kt
+++ b/build-logic/src/main/kotlin/LicenseFileValidation.kt
@@ -24,8 +24,8 @@ import java.io.File
import org.gradle.api.GradleException
/**
- * Validates that all dependencies with MIT/BSD/Go/UPL/ISC licenses, and Apache
- * license, are mentioned in the `LICENSE` file.
+ * Validates that all dependencies with MIT/BSD/Go/UPL/ISC licenses, and Apache license, are
+ * mentioned in the `LICENSE` file.
*/
class LicenseFileValidation : DependencyFilter {
val needsApacheLicenseMention = setOf("Apache")
@@ -78,7 +78,8 @@ class LicenseFileValidation : DependencyFilter {
if (doesNeedApacheMention(licenses)) {
missingApacheMentions.add(groupModule)
} else if (doesNeedFullMention(licenses)) {
- missingFullMentions[groupModule] = """
+ missingFullMentions[groupModule] =
+ """
---
$groupModule
@@ -88,7 +89,8 @@ class LicenseFileValidation : DependencyFilter {
.map { "\n\n$it\n" }
.joinToString("\n")
}
- """.trimIndent()
+ """
+ .trimIndent()
}
}
}
@@ -97,16 +99,12 @@ class LicenseFileValidation : DependencyFilter {
if (!missingApacheMentions.isEmpty()) {
missingError.append("\n\nMissing Apache License mentions:")
missingError.append("\n--------------------------------\n")
- missingApacheMentions.sorted().forEach {
- missingError.append("\n$it")
- }
+ missingApacheMentions.sorted().forEach { missingError.append("\n$it") }
}
if (!missingFullMentions.isEmpty()) {
missingError.append("\n\nMissing full license mentions:")
missingError.append("\n------------------------------\n")
- missingFullMentions.toSortedMap().values.forEach {
- missingError.append("\n$it")
- }
+ missingFullMentions.toSortedMap().values.forEach { missingError.append("\n$it") }
}
if (!missingApacheMentions.isEmpty() || !missingFullMentions.isEmpty()) {
diff --git a/build-logic/src/main/kotlin/polaris-root.gradle.kts b/build-logic/src/main/kotlin/polaris-root.gradle.kts
index 40aa3c49..b2249749 100644
--- a/build-logic/src/main/kotlin/polaris-root.gradle.kts
+++ b/build-logic/src/main/kotlin/polaris-root.gradle.kts
@@ -34,7 +34,7 @@ spotless {
kotlinGradle {
ktfmt().googleStyle()
licenseHeaderFile(rootProject.file("codestyle/copyright-header-java.txt"), "$")
- target("*.gradle.kts", "build-logic/*.gradle.kts", "build-logic/src/**/*.kts")
+ target("*.gradle.kts", "build-logic/*.gradle.kts", "build-logic/src/**/*.kt*")
}
}
diff --git a/build-logic/src/main/kotlin/publishing/MemoizedGitInfo.kt b/build-logic/src/main/kotlin/publishing/MemoizedGitInfo.kt
index df56de76..9cc3abb5 100644
--- a/build-logic/src/main/kotlin/publishing/MemoizedGitInfo.kt
+++ b/build-logic/src/main/kotlin/publishing/MemoizedGitInfo.kt
@@ -19,16 +19,17 @@
package publishing
+import java.io.ByteArrayOutputStream
+import java.nio.charset.StandardCharsets
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.java.archives.Attributes
import org.gradle.kotlin.dsl.extra
-import java.io.ByteArrayOutputStream
-import java.nio.charset.StandardCharsets
/**
- * Container to memoize Git information retrieved via `git` command executions across all Gradle projects.
- * Jar release artifacts get some attributes added to the jar manifest, which can be quite useful for released jars.
+ * Container to memoize Git information retrieved via `git` command executions across all Gradle
+ * projects. Jar release artifacts get some attributes added to the jar manifest, which can be quite
+ * useful for released jars.
*/
internal class MemoizedGitInfo {
companion object {
@@ -54,15 +55,16 @@ internal class MemoizedGitInfo {
} else {
val isRelease = rootProject.hasProperty("release")
val gitHead = execProc(rootProject, "git", "rev-parse", "HEAD")
- val gitDescribe = if (isRelease) {
+ val gitDescribe =
+ if (isRelease) {
try {
execProc(rootProject, "git", "describe", "--tags")
} catch (e: Exception) {
throw GradleException("'git describe --tags' failed - no Git tag?", e)
}
- } else {
+ } else {
execProc(rootProject, "git", "describe", "--always", "--dirty")
- }
+ }
val timestamp = execProc(rootProject, "date", "+%Y-%m-%d-%H:%M:%S%:z")
val system = execProc(rootProject, "uname", "-a")
val javaVersion = System.getProperty("java.version")
@@ -82,4 +84,4 @@ internal class MemoizedGitInfo {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/build-logic/src/main/kotlin/publishing/PublishingHelperExtension.kt b/build-logic/src/main/kotlin/publishing/PublishingHelperExtension.kt
index 7ec06a83..335ab118 100644
--- a/build-logic/src/main/kotlin/publishing/PublishingHelperExtension.kt
+++ b/build-logic/src/main/kotlin/publishing/PublishingHelperExtension.kt
@@ -19,35 +19,45 @@
package publishing
+import java.io.File
+import javax.inject.Inject
import org.gradle.api.Project
import org.gradle.api.model.ObjectFactory
import org.gradle.kotlin.dsl.listProperty
import org.gradle.kotlin.dsl.property
-import java.io.File
-import javax.inject.Inject
/**
- * Gradle plugin extension object for the `PublishingHelperPlugin. Most attributes are likely never changed from the
- * default values.
+ * Gradle plugin extension object for the `PublishingHelperPlugin. Most attributes are likely never
+ * changed from the default values.
*
- * Apache podlings need to specify the PPMC members and committers manually, Apache TLPs don't populate these
- * properties.
+ * Apache podlings need to specify the PPMC members and committers manually, Apache TLPs don't
+ * populate these properties.
*/
abstract class PublishingHelperExtension
@Inject
-constructor(objectFactory: ObjectFactory, project: Project)
-{
+constructor(objectFactory: ObjectFactory, project: Project) {
// optional customization of the pom.xml <name> element
val mavenName = objectFactory.property<String>().convention(project.provider { project.name })
- val licenseUrl = objectFactory.property<String>().convention("https://www.apache.org/licenses/LICENSE-2.0.txt")
+ val licenseUrl =
+ objectFactory.property<String>().convention("https://www.apache.org/licenses/LICENSE-2.0.txt")
// the following are only relevant on the root project
val asfProjectName = objectFactory.property<String>()
- val baseName = objectFactory.property<String>().convention(project.provider { "apache-${asfProjectName.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") })
- val sourceTarballDigest = objectFactory.fileProperty().convention(project.provider { distributionDir.get().file("${baseName.get()}.sha512") })
+ val baseName =
+ objectFactory
+ .property<String>()
+ .convention(project.provider { "apache-${asfProjectName.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") })
+ val sourceTarballDigest =
+ objectFactory
+ .fileProperty()
+ .convention(project.provider { distributionDir.get().file("${baseName.get()}.sha512") })
val mailingLists = objectFactory.listProperty(String::class.java).convention(emptyList())
diff --git a/build-logic/src/main/kotlin/publishing/PublishingHelperPlugin.kt b/build-logic/src/main/kotlin/publishing/PublishingHelperPlugin.kt
index 5dbae0a5..7bb9960e 100644
--- a/build-logic/src/main/kotlin/publishing/PublishingHelperPlugin.kt
+++ b/build-logic/src/main/kotlin/publishing/PublishingHelperPlugin.kt
@@ -20,38 +20,40 @@
package publishing
import com.github.jengelman.gradle.plugins.shadow.ShadowExtension
-import org.gradle.api.*
import javax.inject.Inject
+import org.gradle.api.*
import org.gradle.api.component.SoftwareComponentFactory
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
import org.gradle.api.publish.tasks.GenerateModuleMetadata
+import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.*
import org.gradle.plugins.signing.SigningExtension
import org.gradle.plugins.signing.SigningPlugin
-import org.gradle.jvm.tasks.Jar
-/** Release-publishing helper plugin to generate publications that pass Sonatype validations,
- * generate Apache release source tarball.
+/**
+ * Release-publishing helper plugin to generate publications that pass Sonatype validations,
+ * generate Apache release source tarball.
*
- * The `release` Gradle project property triggers: signed artifacts + jars with Git information.
- * The current Git HEAD must point to a Git tag.
+ * The `release` Gradle project property triggers: signed artifacts + jars with Git information. The
+ * current Git HEAD must point to a Git tag.
*
* The `jarWithGitInfo` Gradle project property triggers: jars with Git information (not necessary
* with `release`).
*
- * The task `sourceTarball` (available on the root project) generates a source tarball using
- * `git archive`.
+ * The task `sourceTarball` (available on the root project) generates a source tarball using `git
+ * archive`.
+ *
+ * The task `releaseEmailTemplate` generates the release-vote email subject + body. Outputs on the
+ * console and in the `build/distributions/` directory.
*
- * The task `releaseEmailTemplate` generates the release-vote email subject + body. Outputs on
- * the console and in the `build/distributions/` directory.
+ * Signing tip: If you want to use `gpg-agent`, set the `useGpgAgent` Gradle project property
*
- * Signing tip: If you want to use `gpg-agent`, set the `useGpgAgent` Gradle project property
+ * The following command publishes the project artifacts to your local maven repository, generates
+ * the source tarball - and uses `gpg-agent` to sign all artifacts and the tarball. Note that this
+ * requires a Git tag!
*
- * The following command publishes the project artifacts to your local maven repository,
- * generates the source tarball - and uses `gpg-agent` to sign all artifacts and the tarball.
- * Note that this requires a Git tag!
* ```
* ./gradlew publishToMavenLocal sourceTarball -Prelease -PuseGpgAgent
* ```
@@ -144,4 +146,3 @@ constructor(private val softwareComponentFactory: SoftwareComponentFactory) : Pl
}
}
}
-
diff --git a/build-logic/src/main/kotlin/publishing/configurePom.kt b/build-logic/src/main/kotlin/publishing/configurePom.kt
index e33cbf48..ee452dc2 100644
--- a/build-logic/src/main/kotlin/publishing/configurePom.kt
+++ b/build-logic/src/main/kotlin/publishing/configurePom.kt
@@ -31,187 +31,204 @@ import org.gradle.internal.extensions.stdlib.capitalized
/**
* Configures the content of the generated `pom.xml` files.
*
- * For all projects except the root project, the pom gets the `<license>`, `<name>`, `<description>`, `<parent>`
- * elements and fixes dependencies in `<dependencyManagement>` to be consumable by Maven.
+ * For all projects except the root project, the pom gets the `<license>`, `<name>`,
+ * `<description>`, `<parent>` elements and fixes dependencies in `<dependencyManagement>` to be
+ * consumable by Maven.
*
- * The root project generates the parent pom, containing all the necessary elements to pass Sonatype validation
- * and some more information like `<developers>` and `<contributors>`. Most of the information is taken from publicly
- * consumable Apache project information from `https://projects.apache.org/json/projects/<project-name>>.json`.
- * `<developers>` contains all (P)PMC members and committers from that project info JSON, ordered by real name.
- * `<contributors>` is taken from GitHub's `https://api.github.com/repos/apache/<project-name>/contributors?per_page=1000`
- * endpoint to give all contributors credit, ordered by number of contributions (as returned by that endpoint).
+ * The root project generates the parent pom, containing all the necessary elements to pass Sonatype
+ * validation and some more information like `<developers>` and `<contributors>`. Most of the
+ * information is taken from publicly consumable Apache project information from
+ * `https://projects.apache.org/json/projects/<project-name>>.json`. `<developers>` contains all
+ * (P)PMC members and committers from that project info JSON, ordered by real name. `<contributors>`
+ * is taken from GitHub's
+ * `https://api.github.com/repos/apache/<project-name>/contributors?per_page=1000` endpoint to give
+ * all contributors credit, ordered by number of contributions (as returned by that endpoint).
*/
-internal fun configurePom(project: Project, mavenPublication: MavenPublication, task: Task) = mavenPublication.run {
+internal fun configurePom(project: Project, mavenPublication: MavenPublication, task: Task) =
+ mavenPublication.run {
val e = project.extensions.getByType(PublishingHelperExtension::class.java)
pom {
- if (project != project.rootProject) {
- name.set(e.mavenName.get())
- description.set(project.description)
-
- // Add the license to every pom to make it easier for downstream project to retrieve the license.
- licenses {
- license {
- name.set("Apache-2.0") // SPDX identifier
- url.set(e.licenseUrl.get())
- }
- }
+ if (project != project.rootProject) {
+ name.set(e.mavenName.get())
+ description.set(project.description)
+
+ // Add the license to every pom to make it easier for downstream project to retrieve the
+ // license.
+ licenses {
+ license {
+ name.set("Apache-2.0") // SPDX identifier
+ url.set(e.licenseUrl.get())
+ }
+ }
+
+ withXml {
+ val projectNode = asNode()
+
+ val parentNode = projectNode.appendNode("parent")
+ val parent = project.parent!!
+ parentNode.appendNode("groupId", parent.group)
+ parentNode.appendNode("artifactId", parent.name)
+ parentNode.appendNode("version", parent.version)
+
+ addMissingMandatoryDependencyVersions(project, projectNode)
+ }
+ } else {
+ val mavenPom = this
+
+ task.doFirst {
+ val asfName = e.asfProjectName.get()
+ val (asfPrj, fromPodlings) = fetchAsfProject(asfName)
- withXml {
- val projectNode = asNode()
+ val asfProjectName = asfPrj["name"] as String
- val parentNode = projectNode.appendNode("parent")
- val parent = project.parent!!
- parentNode.appendNode("groupId", parent.group)
- parentNode.appendNode("artifactId", parent.name)
- parentNode.appendNode("version", parent.version)
+ mavenPom.name.set(asfProjectName)
+ mavenPom.description.set(asfPrj["description"] as String)
- addMissingMandatoryDependencyVersions(project, projectNode)
+ inceptionYear.set(
+ (asfPrj["created"] ?: asfPrj["started"]!!).toString().replace("(\\d+)-.*", "\\1")
+ )
+ url.set(asfPrj["homepage"] as String)
+ organization {
+ name.set("The Apache Software Foundation")
+ url.set("https://www.apache.org/")
+ }
+ licenses {
+ license {
+ name.set("Apache-2.0") // SPDX identifier
+ url.set(e.licenseUrl.get())
}
- } else {
- val mavenPom = this
-
- task.doFirst {
- val asfName = e.asfProjectName.get()
- val (asfPrj, fromPodlings) = fetchAsfProject(asfName)
-
- val asfProjectName = asfPrj["name"] as String
-
- mavenPom.name.set(asfProjectName)
- mavenPom.description.set(asfPrj["description"] as String)
-
- inceptionYear.set((asfPrj["created"] ?: asfPrj["started"]!!).toString().replace("(\\d+)-.*", "\\1"))
- url.set(asfPrj["homepage"] as String)
- organization {
- name.set("The Apache Software Foundation")
- url.set("https://www.apache.org/")
- }
- licenses {
- license {
- name.set("Apache-2.0") // SPDX identifier
- url.set(e.licenseUrl.get())
- }
- }
- mailingLists {
- e.mailingLists.get().forEach { ml ->
- mailingList {
- name.set("${ml.capitalized()} Mailing List")
- subscribe.set("$ml-subscribe@$asfName.apache.org")
- unsubscribe.set("$ml-ubsubscribe@$asfName.apache.org")
- post.set("$ml@$asfName.apache.org")
- archive.set("https://lists.apache.org/list.html?$ml@$asfName.apache.org")
- }
- }
- }
- scm {
- val codeRepo: String = if (asfPrj.contains("repository")) {
- val repos: List<String> = unsafeCast(asfPrj["repository"]) as List<String>
- repos[0]
- } else {
- "https://github.com/apache/$asfName.git"
- }
- connection.set("scm:git:$codeRepo")
- developerConnection.set("scm:git:$codeRepo")
- url.set("$codeRepo/tree/main")
- tag.set("main")
- }
- issueManagement {
- url.set(if (asfPrj.contains("repository")) {
- asfPrj["bug-database"] as String
- } else {
- "https://github.com/apache/$asfName/issues"
- })
- }
- addDevelopersToPom(mavenPom, asfName, e, fromPodlings)
- addContributorsToPom(mavenPom, asfName, asfProjectName)
+ }
+ mailingLists {
+ e.mailingLists.get().forEach { ml ->
+ mailingList {
+ name.set("${ml.capitalized()} Mailing List")
+ subscribe.set("$ml-subscribe@$asfName.apache.org")
+ unsubscribe.set("$ml-ubsubscribe@$asfName.apache.org")
+ post.set("$ml@$asfName.apache.org")
+ archive.set("https://lists.apache.org/list.html?$ml@$asfName.apache.org")
+ }
}
+ }
+ scm {
+ val codeRepo: String =
+ if (asfPrj.contains("repository")) {
+ val repos: List<String> = unsafeCast(asfPrj["repository"]) as List<String>
+ repos[0]
+ } else {
+ "https://github.com/apache/$asfName.git"
+ }
+ connection.set("scm:git:$codeRepo")
+ developerConnection.set("scm:git:$codeRepo")
+ url.set("$codeRepo/tree/main")
+ tag.set("main")
+ }
+ issueManagement {
+ url.set(
+ if (asfPrj.contains("repository")) {
+ asfPrj["bug-database"] as String
+ } else {
+ "https://github.com/apache/$asfName/issues"
+ }
+ )
+ }
+ addDevelopersToPom(mavenPom, asfName, e, fromPodlings)
+ addContributorsToPom(mavenPom, asfName, asfProjectName)
}
+ }
}
-}
+ }
-/**
- * Adds contributors as returned by GitHub, in descending `contributions` order.
- */
-fun addContributorsToPom(mavenPom: MavenPom, asfName: String, asfProjectName: String) = mavenPom.run {
+/** Adds contributors as returned by GitHub, in descending `contributions` order. */
+fun addContributorsToPom(mavenPom: MavenPom, asfName: String, asfProjectName: String) =
+ mavenPom.run {
contributors {
- val contributors: List<Map<String, Any>>? =
- parseJson("https://api.github.com/repos/apache/$asfName/contributors?per_page=1000")
- if (contributors != null) {
- contributors.filter { contributor ->
- contributor["type"] == "User"
- }.forEach { contributor ->
- contributor {
- name.set(contributor["login"] as String)
- url.set(contributor["url"] as String)
- organization.set("$asfProjectName, GitHub contributors")
- organizationUrl.set("https://github.com/apache/$asfName")
- }
+ val contributors: List<Map<String, Any>>? =
+ parseJson("https://api.github.com/repos/apache/$asfName/contributors?per_page=1000")
+ if (contributors != null) {
+ contributors
+ .filter { contributor -> contributor["type"] == "User" }
+ .forEach { contributor ->
+ contributor {
+ name.set(contributor["login"] as String)
+ url.set(contributor["url"] as String)
+ organization.set("$asfProjectName, GitHub contributors")
+ organizationUrl.set("https://github.com/apache/$asfName")
}
- }
+ }
+ }
}
-}
+ }
-/**
- * Adds Apache (P)PMC members + committers, in `name` order.
- */
-fun addDevelopersToPom(mavenPom: MavenPom, asfName: String, e: PublishingHelperExtension, fromPodlings: Boolean) = mavenPom.run {
+/** Adds Apache (P)PMC members + committers, in `name` order. */
+fun addDevelopersToPom(
+ mavenPom: MavenPom,
+ asfName: String,
+ e: PublishingHelperExtension,
+ fromPodlings: Boolean
+) =
+ mavenPom.run {
developers {
- // Cannot use check the 'groups' for podlings, because the (only) podling's group
- // references the mentors, not the PPMC members/committers. There seems to be no
- // way to automatically fetch the committers + PPMC members for a podling, except
- // maybe
- val people: Map<String, Map<String, Any>> =
- parseJson("https://projects.apache.org/json/foundation/people.json")!!
- val filteredPeople: List<Pair<String, Map<String, Any>>>
- val pmc: (Pair<String, Map<String, Any>>) -> Boolean
- val mentor: (Pair<String, Map<String, Any>>) -> Boolean
- val pmcRole: String
- if (!fromPodlings) {
- val asfNamePmc = "$asfName-pmc"
- filteredPeople = people.filter { entry ->
- val groups: List<String> = unsafeCast(entry.value["groups"])
- groups.any { it == asfName || it == asfNamePmc }
- }.toList()
- pmc = {(_, info) ->
- val groups: List<String> = unsafeCast(info["groups"])
- groups.contains(asfNamePmc)
+ // Cannot use check the 'groups' for podlings, because the (only) podling's group
+ // references the mentors, not the PPMC members/committers. There seems to be no
+ // way to automatically fetch the committers + PPMC members for a podling, except
+ // maybe
+ val people: Map<String, Map<String, Any>> =
+ parseJson("https://projects.apache.org/json/foundation/people.json")!!
+ val filteredPeople: List<Pair<String, Map<String, Any>>>
+ val pmc: (Pair<String, Map<String, Any>>) -> Boolean
+ val mentor: (Pair<String, Map<String, Any>>) -> Boolean
+ val pmcRole: String
+ if (!fromPodlings) {
+ val asfNamePmc = "$asfName-pmc"
+ filteredPeople =
+ people
+ .filter { entry ->
+ val groups: List<String> = unsafeCast(entry.value["groups"])
+ groups.any { it == asfName || it == asfNamePmc }
}
- pmcRole = "PMC Member"
- mentor = {(_, _) -> false}
- } else {
- val podlingPpmc = e.podlingPpmcAsfIds.get()
- val podlingMentors = e.podlingMentorsAsfIds.get()
- filteredPeople = (e.podlingCommitterAsfIds.get() + podlingPpmc + podlingMentors).map { id ->
- val info = people[id]
- if (info == null) {
- throw GradleException("Person with ASF id '%id' not found in people.json".format(id))
- }
- Pair(id, info)
- }
- pmc = {(id, _) -> podlingPpmc.contains(id) || podlingMentors.contains(id)}
- pmcRole = "PPMC Member"
- mentor = {(id, _) -> podlingMentors.contains(id)}
+ .toList()
+ pmc = { (_, info) ->
+ val groups: List<String> = unsafeCast(info["groups"])
+ groups.contains(asfNamePmc)
}
-
- val sortedPeople = filteredPeople.sortedBy { (id, info) -> "${info["name"] as String}_$id" }
-
- sortedPeople.forEach { (id, info) ->
- developer {
- this.id.set(id)
- this.name.set(info["name"] as String)
- this.organization.set("Apache Software Foundation")
- this.email.set("$id@apache.org")
- this.roles.add("Committer")
- if (pmc.invoke(Pair(id, info))) {
- this.roles.add(pmcRole)
- }
- if (mentor.invoke(Pair(id, info))) {
- this.roles.add("Mentor")
- }
+ pmcRole = "PMC Member"
+ mentor = { (_, _) -> false }
+ } else {
+ val podlingPpmc = e.podlingPpmcAsfIds.get()
+ val podlingMentors = e.podlingMentorsAsfIds.get()
+ filteredPeople =
+ (e.podlingCommitterAsfIds.get() + podlingPpmc + podlingMentors).map { id ->
+ val info = people[id]
+ if (info == null) {
+ throw GradleException("Person with ASF id '%id' not found in people.json".format(id))
}
+ Pair(id, info)
+ }
+ pmc = { (id, _) -> podlingPpmc.contains(id) || podlingMentors.contains(id) }
+ pmcRole = "PPMC Member"
+ mentor = { (id, _) -> podlingMentors.contains(id) }
+ }
+
+ val sortedPeople = filteredPeople.sortedBy { (id, info) -> "${info["name"] as String}_$id" }
+
+ sortedPeople.forEach { (id, info) ->
+ developer {
+ this.id.set(id)
+ this.name.set(info["name"] as String)
+ this.organization.set("Apache Software Foundation")
+ this.email.set("$id@apache.org")
+ this.roles.add("Committer")
+ if (pmc.invoke(Pair(id, info))) {
+ this.roles.add(pmcRole)
+ }
+ if (mentor.invoke(Pair(id, info))) {
+ this.roles.add("Mentor")
+ }
}
+ }
}
-}
+ }
/**
* Scans the generated `pom.xml` for `<dependencies>` in `<dependencyManagement>` that do not have a
@@ -219,23 +236,27 @@ fun addDevelopersToPom(mavenPom: MavenPom, asfName: String, e: PublishingHelperE
* `<dependency>` without a `<version>` is a bom and that bom's version is available transitively.
*/
fun addMissingMandatoryDependencyVersions(project: Project, projectNode: Node) {
- xmlNode(xmlNode(projectNode, "dependencyManagement"), "dependencies")?.children()?.forEach {
- val dependency = it as Node
- if (xmlNode(dependency, "version") == null) {
- val depGroup = xmlNode(dependency, "groupId")!!.text()
- val depName = xmlNode(dependency, "artifactId")!!.text()
-
- var depResult =
- findDependency(project.configurations.findByName("runtimeClasspath"), depGroup, depName)
- if (depResult == null) {
- depResult =
- findDependency(project.configurations.findByName("testRuntimeClasspath"), depGroup, depName)
- }
+ xmlNode(xmlNode(projectNode, "dependencyManagement"), "dependencies")?.children()?.forEach {
+ val dependency = it as Node
+ if (xmlNode(dependency, "version") == null) {
+ val depGroup = xmlNode(dependency, "groupId")!!.text()
+ val depName = xmlNode(dependency, "artifactId")!!.text()
- if (depResult != null) {
- val req = depResult.requested as ModuleComponentSelector
- dependency.appendNode("version", req.version)
- }
- }
+ var depResult =
+ findDependency(project.configurations.findByName("runtimeClasspath"), depGroup, depName)
+ if (depResult == null) {
+ depResult =
+ findDependency(
+ project.configurations.findByName("testRuntimeClasspath"),
+ depGroup,
+ depName
+ )
+ }
+
+ if (depResult != null) {
+ val req = depResult.requested as ModuleComponentSelector
+ dependency.appendNode("version", req.version)
+ }
}
+ }
}
diff --git a/build-logic/src/main/kotlin/publishing/rootProject.kt b/build-logic/src/main/kotlin/publishing/rootProject.kt
index 3d14a1cb..20566881 100644
--- a/build-logic/src/main/kotlin/publishing/rootProject.kt
+++ b/build-logic/src/main/kotlin/publishing/rootProject.kt
@@ -22,7 +22,6 @@ package publishing
import io.github.gradlenexus.publishplugin.NexusPublishExtension
import io.github.gradlenexus.publishplugin.NexusPublishPlugin
import io.github.gradlenexus.publishplugin.internal.StagingRepositoryDescriptorRegistryBuildService
-import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.services.BuildServiceRegistration
import org.gradle.kotlin.dsl.apply
@@ -31,107 +30,122 @@ import org.gradle.kotlin.dsl.register
import org.gradle.plugins.signing.Sign
/**
- * Configures Apache project specific publishing tasks on the root project, for example the source-tarball related tasks.
+ * Configures Apache project specific publishing tasks on the root project, for example the
+ * source-tarball related tasks.
*/
-internal fun configureOnRootProject(project: Project) = project.run {
+internal fun configureOnRootProject(project: Project) =
+ project.run {
apply<NexusPublishPlugin>()
val isRelease = project.hasProperty("release")
val isSigning = isRelease || project.hasProperty("signArtifacts")
val sourceTarball = tasks.register("sourceTarball")
- sourceTarball.configure(){
- group = "build"
- description = "Generate a source tarball for a release to be uploaded to dist.apache.org/repos/dist"
-
- doFirst {
- val e = project.extensions.getByType(PublishingHelperExtension::class.java)
- mkdir(e.distributionDir)
- exec {
- executable = "git"
- args("archive", "--prefix=${e.baseName.get()}/", "--format=tar.gz", "--output=${e.sourceTarball.get().asFile.relativeTo(projectDir)}", "HEAD")
- workingDir(project.projectDir)
- }
+ sourceTarball.configure() {
+ group = "build"
+ description =
+ "Generate a source tarball for a release to be uploaded to dist.apache.org/repos/dist"
+
+ doFirst {
+ val e = project.extensions.getByType(PublishingHelperExtension::class.java)
+ mkdir(e.distributionDir)
+ exec {
+ executable = "git"
+ args(
+ "archive",
+ "--prefix=${e.baseName.get()}/",
+ "--format=tar.gz",
+ "--output=${e.sourceTarball.get().asFile.relativeTo(projectDir)}",
+ "HEAD"
+ )
+ workingDir(project.projectDir)
}
+ }
}
val digestSourceTarball = tasks.register("digestSourceTarball")
digestSourceTarball.configure {
- mustRunAfter(sourceTarball)
+ mustRunAfter(sourceTarball)
- doFirst {
- val e = project.extensions.getByType(PublishingHelperExtension::class.java)
- generateDigest(e.sourceTarball.get().asFile, e.sourceTarballDigest.get().asFile, "SHA-512")
- }
+ doFirst {
+ val e = project.extensions.getByType(PublishingHelperExtension::class.java)
+ generateDigest(e.sourceTarball.get().asFile, e.sourceTarballDigest.get().asFile, "SHA-512")
+ }
}
- sourceTarball.configure {
- finalizedBy(digestSourceTarball)
- }
+ sourceTarball.configure { finalizedBy(digestSourceTarball) }
if (isSigning) {
- val signSourceTarball = tasks.register<Sign>("signSourceTarball")
- signSourceTarball.configure {
- mustRunAfter(sourceTarball)
- doFirst {
- val e = project.extensions.getByType(PublishingHelperExtension::class.java)
- sign(e.sourceTarball.get().asFile)
- }
- }
- sourceTarball.configure {
- finalizedBy(signSourceTarball)
+ val signSourceTarball = tasks.register<Sign>("signSourceTarball")
+ signSourceTarball.configure {
+ mustRunAfter(sourceTarball)
+ doFirst {
+ val e = project.extensions.getByType(PublishingHelperExtension::class.java)
+ sign(e.sourceTarball.get().asFile)
}
+ }
+ sourceTarball.configure { finalizedBy(signSourceTarball) }
}
val releaseEmailTemplate = tasks.register("releaseEmailTemplate")
releaseEmailTemplate.configure {
- group = "publishing"
- description = "Generate release-vote email subject + body, including the staging repository URL, if run during the Maven release."
-
- mustRunAfter("initializeApacheStagingRepository")
-
- doFirst {
- val e = project.extensions.getByType(PublishingHelperExtension::class.java)
- val asfName = e.asfProjectName.get()
-
- val gitInfo = MemoizedGitInfo.gitInfo(rootProject)
- val gitCommitId = gitInfo["Apache-Polaris-Build-Git-Head"]
-
- val repos = project.extensions.getByType(NexusPublishExtension::class.java).repositories
- val repo = repos.iterator().next()
-
- val stagingRepositoryUrlRegistryRegistration = gradle.sharedServices.registrations.named<BuildServiceRegistration<StagingRepositoryDescriptorRegistryBuildService, *>>("stagingRepositoryUrlRegistry")
- val staginRepoUrl = if (stagingRepositoryUrlRegistryRegistration.isPresent) {
- val stagingRepositoryUrlRegistryBuildServiceRegistration = stagingRepositoryUrlRegistryRegistration.get()
- val stagingRepositoryUrlRegistryService = stagingRepositoryUrlRegistryBuildServiceRegistration.getService()
- if (stagingRepositoryUrlRegistryService.isPresent) {
- val registry = stagingRepositoryUrlRegistryService.get().registry
- try {
- val stagingRepoDesc = registry.get(repo.name)
- val stagingRepoId = stagingRepoDesc.stagingRepositoryId
- "https://repository.apache.org/content/repositories/$stagingRepoId/"
- } catch (e: IllegalStateException) {
- "NO STAGING REPOSITORY ($e)"
- }
- } else {
- "NO STAGING REPOSITORY (no registry service) !!"
- }
+ group = "publishing"
+ description =
+ "Generate release-vote email subject + body, including the staging repository URL, if run during the Maven release."
+
+ mustRunAfter("initializeApacheStagingRepository")
+
+ doFirst {
+ val e = project.extensions.getByType(PublishingHelperExtension::class.java)
+ val asfName = e.asfProjectName.get()
+
+ val gitInfo = MemoizedGitInfo.gitInfo(rootProject)
+ val gitCommitId = gitInfo["Apache-Polaris-Build-Git-Head"]
+
+ val repos = project.extensions.getByType(NexusPublishExtension::class.java).repositories
+ val repo = repos.iterator().next()
+
+ val stagingRepositoryUrlRegistryRegistration =
+ gradle.sharedServices.registrations.named<
+ BuildServiceRegistration<StagingRepositoryDescriptorRegistryBuildService, *>
+ >(
+ "stagingRepositoryUrlRegistry"
+ )
+ val staginRepoUrl =
+ if (stagingRepositoryUrlRegistryRegistration.isPresent) {
+ val stagingRepositoryUrlRegistryBuildServiceRegistration =
+ stagingRepositoryUrlRegistryRegistration.get()
+ val stagingRepositoryUrlRegistryService =
+ stagingRepositoryUrlRegistryBuildServiceRegistration.getService()
+ if (stagingRepositoryUrlRegistryService.isPresent) {
+ val registry = stagingRepositoryUrlRegistryService.get().registry
+ try {
+ val stagingRepoDesc = registry.get(repo.name)
+ val stagingRepoId = stagingRepoDesc.stagingRepositoryId
+ "https://repository.apache.org/content/repositories/$stagingRepoId/"
+ } catch (e: IllegalStateException) {
+ "NO STAGING REPOSITORY ($e)"
+ }
} else {
- "NO STAGING REPOSITORY (no build service) !!"
+ "NO STAGING REPOSITORY (no registry service) !!"
}
+ } else {
+ "NO STAGING REPOSITORY (no build service) !!"
+ }
- val (asfPrj, _) = fetchAsfProject(asfName)
- val asfProjectName = asfPrj["name"] as String
+ val (asfPrj, _) = fetchAsfProject(asfName)
+ val asfProjectName = asfPrj["name"] as String
- val versionNoRc = version.toString().replace("-rc-?[0-9]+".toRegex(), "")
+ val versionNoRc = version.toString().replace("-rc-?[0-9]+".toRegex(), "")
- val subjectFile = e.distributionFile("vote-email-subject.txt").relativeTo(projectDir)
- val bodyFile = e.distributionFile("vote-email-body.txt").relativeTo(projectDir)
+ val subjectFile = e.distributionFile("vote-email-subject.txt").relativeTo(projectDir)
+ val bodyFile = e.distributionFile("vote-email-body.txt").relativeTo(projectDir)
- val emailSubject = "[VOTE] Release $asfProjectName $version"
- subjectFile.writeText(emailSubject)
+ val emailSubject = "[VOTE] Release $asfProjectName $version"
+ subjectFile.writeText(emailSubject)
- val emailBody = """
+ val emailBody =
+ """
Hi everyone,
I propose that we release the following RC as the official
@@ -167,7 +181,8 @@ internal fun configureOnRootProject(project: Project) = project.run {
Regards
"""
- logger.lifecycle("""
+ logger.lifecycle(
+ """
The email for your release vote mail:
@@ -181,18 +196,18 @@ internal fun configureOnRootProject(project: Project) = project.run {
$emailBody
- """.trimIndent())
- bodyFile.writeText(emailBody.trimIndent())
- }
+ """
+ .trimIndent()
+ )
+ bodyFile.writeText(emailBody.trimIndent())
+ }
}
if (isRelease) {
- sourceTarball.configure {
- finalizedBy(releaseEmailTemplate)
- }
+ sourceTarball.configure { finalizedBy(releaseEmailTemplate) }
}
afterEvaluate {
- tasks.named("closeApacheStagingRepository") { mustRunAfter(releaseEmailTemplate) }
+ tasks.named("closeApacheStagingRepository") { mustRunAfter(releaseEmailTemplate) }
}
-}
+ }
diff --git a/build-logic/src/main/kotlin/publishing/shadowPub.kt b/build-logic/src/main/kotlin/publishing/shadowPub.kt
index 4fb78410..90f007c7 100644
--- a/build-logic/src/main/kotlin/publishing/shadowPub.kt
+++ b/build-logic/src/main/kotlin/publishing/shadowPub.kt
@@ -32,7 +32,6 @@ import org.gradle.api.component.SoftwareComponentFactory
import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.publish.maven.MavenPublication
-
/**
* "Proper" publication of shadow-jar instead of the "main" jar, with "the right" Gradle's module
* metadata that refers to the shadow-jar instead of the "main" jar, which is not published by
@@ -40,57 +39,62 @@ import org.gradle.api.publish.maven.MavenPublication
*
* Pieces of this function are taken from the `Java(Base)Plugin` and `ShadowExtension`.
*/
-internal fun configureShadowPublishing(project: Project, mavenPublication: MavenPublication, softwareComponentFactory: SoftwareComponentFactory) = project.run {
+internal fun configureShadowPublishing(
+ project: Project,
+ mavenPublication: MavenPublication,
+ softwareComponentFactory: SoftwareComponentFactory
+) =
+ project.run {
fun isPublishable(element: ConfigurationVariant): Boolean {
- for (artifact in element.artifacts) {
- if (JavaBasePlugin.UNPUBLISHABLE_VARIANT_ARTIFACTS.contains(artifact.type)) {
- return false
- }
+ for (artifact in element.artifacts) {
+ if (JavaBasePlugin.UNPUBLISHABLE_VARIANT_ARTIFACTS.contains(artifact.type)) {
+ return false
}
- return true
+ }
+ return true
}
val shadowJar = project.tasks.named("shadowJar")
val shadowApiElements =
- project.configurations.create("shadowApiElements") {
- isCanBeConsumed = true
- isCanBeResolved = false
- attributes {
- attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, Usage.JAVA_API))
- attribute(
- Category.CATEGORY_ATTRIBUTE,
- project.objects.named(Category::class.java, Category.LIBRARY)
- )
- attribute(
- LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE,
- project.objects.named(LibraryElements::class.java, LibraryElements.JAR)
- )
- attribute(
- Bundling.BUNDLING_ATTRIBUTE,
- project.objects.named(Bundling::class.java, Bundling.SHADOWED)
- )
- }
- outgoing.artifact(shadowJar)
+ project.configurations.create("shadowApiElements") {
+ isCanBeConsumed = true
+ isCanBeResolved = false
+ attributes {
+ attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, Usage.JAVA_API))
+ attribute(
+ Category.CATEGORY_ATTRIBUTE,
+ project.objects.named(Category::class.java, Category.LIBRARY)
+ )
+ attribute(
+ LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE,
+ project.objects.named(LibraryElements::class.java, LibraryElements.JAR)
+ )
+ attribute(
+ Bundling.BUNDLING_ATTRIBUTE,
+ project.objects.named(Bundling::class.java, Bundling.SHADOWED)
+ )
}
+ outgoing.artifact(shadowJar)
+ }
val component = softwareComponentFactory.adhoc("shadow")
component.addVariantsFromConfiguration(shadowApiElements) {
- if (isPublishable(configurationVariant)) {
- mapToMavenScope("compile")
- } else {
- skip()
- }
+ if (isPublishable(configurationVariant)) {
+ mapToMavenScope("compile")
+ } else {
+ skip()
+ }
}
// component.addVariantsFromConfiguration(configurations.getByName("runtimeElements")) {
component.addVariantsFromConfiguration(
- project.configurations.getByName("shadowRuntimeElements")
+ project.configurations.getByName("shadowRuntimeElements")
) {
- if (isPublishable(configurationVariant)) {
- mapToMavenScope("runtime")
- } else {
- skip()
- }
+ if (isPublishable(configurationVariant)) {
+ mapToMavenScope("runtime")
+ } else {
+ skip()
+ }
}
// Sonatype requires the javadoc and sources jar to be present, but the
// Shadow extension does not publish those.
@@ -102,24 +106,24 @@ internal fun configureShadowPublishing(project: Project, mavenPublication: Maven
// 'shadowExtension.component(mavenPublication)', which we cannot use.
mavenPublication.pom {
- withXml {
- val node = asNode()
- val depNode = node.get("dependencies")
- val dependenciesNode =
- if ((depNode as NodeList).isNotEmpty()) depNode[0] as Node
- else node.appendNode("dependencies")
- project.configurations.getByName("shadow").allDependencies.forEach {
- @Suppress("DEPRECATION")
- if (
- (it is ProjectDependency) || it !is org.gradle.api.artifacts.SelfResolvingDependency
- ) {
- val dependencyNode = dependenciesNode.appendNode("dependency")
- dependencyNode.appendNode("groupId", it.group)
- dependencyNode.appendNode("artifactId", it.name)
- dependencyNode.appendNode("version", it.version)
- dependencyNode.appendNode("scope", "runtime")
- }
- }
+ withXml {
+ val node = asNode()
+ val depNode = node.get("dependencies")
+ val dependenciesNode =
+ if ((depNode as NodeList).isNotEmpty()) depNode[0] as Node
+ else node.appendNode("dependencies")
+ project.configurations.getByName("shadow").allDependencies.forEach {
+ @Suppress("DEPRECATION")
+ if (
+ (it is ProjectDependency) || it !is org.gradle.api.artifacts.SelfResolvingDependency
+ ) {
+ val dependencyNode = dependenciesNode.appendNode("dependency")
+ dependencyNode.appendNode("groupId", it.group)
+ dependencyNode.appendNode("artifactId", it.name)
+ dependencyNode.appendNode("version", it.version)
+ dependencyNode.appendNode("scope", "runtime")
+ }
}
+ }
}
-}
+ }
diff --git a/build-logic/src/main/kotlin/publishing/util.kt b/build-logic/src/main/kotlin/publishing/util.kt
index ee5919ce..b3c27310 100644
--- a/build-logic/src/main/kotlin/publishing/util.kt
+++ b/build-logic/src/main/kotlin/publishing/util.kt
@@ -23,87 +23,87 @@ import groovy.json.JsonException
import groovy.json.JsonSlurper
import groovy.util.Node
import groovy.util.NodeList
-import groovy.xml.XmlSlurper
-import groovy.xml.slurpersupport.GPathResult
-import org.gradle.api.GradleException
-import org.gradle.api.artifacts.Configuration
-import org.gradle.api.artifacts.component.ModuleComponentSelector
-import org.gradle.api.artifacts.result.DependencyResult
import java.io.File
import java.io.FileNotFoundException
import java.net.URI
import java.security.MessageDigest
+import org.gradle.api.GradleException
+import org.gradle.api.artifacts.Configuration
+import org.gradle.api.artifacts.component.ModuleComponentSelector
+import org.gradle.api.artifacts.result.DependencyResult
internal fun findDependency(
- config: Configuration?,
- depGroup: String,
- depName: String
+ config: Configuration?,
+ depGroup: String,
+ depName: String
): DependencyResult? {
- if (config != null) {
- val depResult =
- config.incoming.resolutionResult.allDependencies.find { depResult ->
- val req = depResult.requested
- if (req is ModuleComponentSelector) req.group == depGroup && req.module == depName
- else false
- }
- return depResult
- }
- return null
+ if (config != null) {
+ val depResult =
+ config.incoming.resolutionResult.allDependencies.find { depResult ->
+ val req = depResult.requested
+ if (req is ModuleComponentSelector) req.group == depGroup && req.module == depName
+ else false
+ }
+ return depResult
+ }
+ return null
}
internal fun xmlNode(node: Node?, child: String): Node? {
- val found = node?.get(child)
- if (found is NodeList) {
- if (found.isNotEmpty()) {
- return found[0] as Node
- }
+ val found = node?.get(child)
+ if (found is NodeList) {
+ if (found.isNotEmpty()) {
+ return found[0] as Node
}
- return null
+ }
+ return null
}
internal fun generateDigest(input: File, output: File, algorithm: String) {
- val md = MessageDigest.getInstance(algorithm)
- input.inputStream().use {
- val buffered = it.buffered(8192)
- val buf = ByteArray(8192)
- var rd: Int
- while (true) {
- rd = buffered.read(buf)
- if (rd == -1) break
- md.update(buf, 0, rd)
- }
-
- output.writeText(md.digest().joinToString(separator = "") { eachByte -> "%02x".format(eachByte) })
+ val md = MessageDigest.getInstance(algorithm)
+ input.inputStream().use {
+ val buffered = it.buffered(8192)
+ val buf = ByteArray(8192)
+ var rd: Int
+ while (true) {
+ rd = buffered.read(buf)
+ if (rd == -1) break
+ md.update(buf, 0, rd)
}
+
+ output.writeText(
+ md.digest().joinToString(separator = "") { eachByte -> "%02x".format(eachByte) }
+ )
+ }
}
internal fun fetchAsfProject(asfName: String): Pair<Map<String, Any>, Boolean> {
- val tlpPrj: Map<String, Any>? = parseJson("https://projects.apache.org/json/projects/$asfName.json")
- return if (tlpPrj != null) {
- Pair(tlpPrj, false)
- } else {
- val podlings: Map<String, Map<String, Any>> = parseJson("https://projects.apache.org/json/foundation/podlings.json")!!
- val podling = podlings[asfName]
- if (podling == null) {
- throw GradleException("Neither a project nor a podling for $asfName could be found at Apache")
- }
- Pair(podling, true)
+ val tlpPrj: Map<String, Any>? =
+ parseJson("https://projects.apache.org/json/projects/$asfName.json")
+ return if (tlpPrj != null) {
+ Pair(tlpPrj, false)
+ } else {
+ val podlings: Map<String, Map<String, Any>> =
+ parseJson("https://projects.apache.org/json/foundation/podlings.json")!!
+ val podling = podlings[asfName]
+ if (podling == null) {
+ throw GradleException("Neither a project nor a podling for $asfName could be found at Apache")
}
+ Pair(podling, true)
+ }
}
-internal fun <T: Any> unsafeCast(o: Any?): T {
- @Suppress("UNCHECKED_CAST")
- return o as T
+internal fun <T : Any> unsafeCast(o: Any?): T {
+ @Suppress("UNCHECKED_CAST") return o as T
}
-internal fun <T: Any> parseJson(url: String): T? {
- try {
- @Suppress("UNCHECKED_CAST")
- return JsonSlurper().parse(URI(url).toURL()) as T
- } catch (e: JsonException) {
- if (e.cause is FileNotFoundException) {
- return null
- }
- throw e
+internal fun <T : Any> parseJson(url: String): T? {
+ try {
+ @Suppress("UNCHECKED_CAST") return JsonSlurper().parse(URI(url).toURL()) as T
+ } catch (e: JsonException) {
+ if (e.cause is FileNotFoundException) {
+ return null
}
+ throw e
+ }
}