You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by sn...@apache.org on 2024/12/29 11:43:52 UTC

(polaris) branch main updated: Add implementation-* attributes to jar manifest (#596)

This is an automated email from the ASF dual-hosted git repository.

snazy 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 692d03db Add implementation-* attributes to jar manifest (#596)
692d03db is described below

commit 692d03db91d395d2b4d034412ed7082c3648937e
Author: Robert Stupp <sn...@snazy.de>
AuthorDate: Sun Dec 29 12:43:48 2024 +0100

    Add implementation-* attributes to jar manifest (#596)
    
    Adds the following attributes to built jar manifests:
    ```
    Implementation-Title: Apache Polaris(TM) (incubating)
    Implementation-Vendor: Apache Software Foundation
    Implementation-URL: https://polaris.apache.org/
    ```
    
    For release builds, if run with `-Prelease` or `-PjarWithGitInfo`, also adds
    ```
    Implementation-Version: <version-string>
    ```
    in addition to the various `Apache-Polaris-*` manifest attributes.
    
    The `Implementation-*` attributes can be retrieved via Java reflection using the `Class.getPackage().getImplementation*()` functions. NB: Only the `Implementation-Title/Vendor/Version` and `Specification-Title/Vendor/Version` attributes are accessible from `Package`, not other manifest attributes.
---
 build-logic/src/main/kotlin/polaris-java.gradle.kts       | 13 +++++++++++++
 build-logic/src/main/kotlin/publishing/MemoizedGitInfo.kt |  4 +++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/build-logic/src/main/kotlin/polaris-java.gradle.kts b/build-logic/src/main/kotlin/polaris-java.gradle.kts
index 5443fc65..5226fbdd 100644
--- a/build-logic/src/main/kotlin/polaris-java.gradle.kts
+++ b/build-logic/src/main/kotlin/polaris-java.gradle.kts
@@ -66,6 +66,19 @@ tasks.named<Test>("test").configure {
   jvmArgs("-Duser.language=en")
 }
 
+tasks.withType(Jar::class).configureEach {
+  manifest {
+    attributes(
+      // Do not add any (more or less) dynamic information to jars, because that makes Gradle's
+      // caching way less efficient. Note that version and Git information are already added to jar
+      // manifests for release(-like) builds.
+      "Implementation-Title" to "Apache Polaris(TM) (incubating)",
+      "Implementation-Vendor" to "Apache Software Foundation",
+      "Implementation-URL" to "https://polaris.apache.org/"
+    )
+  }
+}
+
 spotless {
   val disallowWildcardImports = { text: String ->
     val regex = "~/import .*\\.\\*;/".toRegex()
diff --git a/build-logic/src/main/kotlin/publishing/MemoizedGitInfo.kt b/build-logic/src/main/kotlin/publishing/MemoizedGitInfo.kt
index d3c9a27e..6479bafc 100644
--- a/build-logic/src/main/kotlin/publishing/MemoizedGitInfo.kt
+++ b/build-logic/src/main/kotlin/publishing/MemoizedGitInfo.kt
@@ -70,9 +70,11 @@ internal class MemoizedGitInfo {
         val system = execProc(rootProject, "uname", "-a")
         val javaVersion = System.getProperty("java.version")
 
+        val version = rootProject.version.toString()
         val info =
           mapOf(
-            "Apache-Polaris-Version" to rootProject.version.toString(),
+            "Implementation-Version" to version,
+            "Apache-Polaris-Version" to version,
             "Apache-Polaris-Is-Release" to isRelease.toString(),
             "Apache-Polaris-Build-Git-Head" to gitHead,
             "Apache-Polaris-Build-Git-Describe" to gitDescribe,