snazy commented on code in PR #591:
URL: https://github.com/apache/polaris/pull/591#discussion_r1898062929


##########
tools/version/src/main/java/org/apache/polaris/version/PolarisVersion.java:
##########
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.version;
+
+import static java.lang.String.format;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.Objects.requireNonNull;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+/**
+ * Utility class to retrieve the current Polaris version and the contents of 
the {@code NOTICE} and
+ * {@code LICENSE*} files.
+ *
+ * <p>If built as a release using the Gradle {@code -Prelease} project 
property, more information
+ * like the Git tag, Git commit ID, build system and more is available as well.
+ */
+public final class PolarisVersion {
+  private PolarisVersion() {}
+
+  /** The version string as in the file {@code version.txt} in the project's 
root directory. */
+  public static String polarisVersionString() {
+    return PolarisVersionNumber.POLARIS_VERSION;
+  }
+
+  /**
+   * Flag whether the build is a released version, when Polaris has been built 
with the Gradle
+   * {@code -Prelease} project property. If {@code true}, the {@code 
getBuild*} functions return
+   * meaningful values.
+   */
+  public static boolean isReleaseBuild() {
+    return 
"true".equals(PolarisVersionJarInfo.buildInfo(MF_IS_RELEASE).orElse("false"));
+  }
+
+  /**
+   * Returns the version as in the jar manifest, if {@linkplain 
#isReleaseBuild() build-time Git
+   * information} is available, when Polaris has been built with the Gradle 
{@code -Prelease}
+   * project property..
+   *
+   * <p>Example value: {@code 1.0.0-incubating-SNAPSHOT}
+   *
+   * @see #isReleaseBuild()
+   */
+  public static Optional<String> getBuildReleasedVersion() {
+    return PolarisVersionJarInfo.buildInfo(MF_VERSION);
+  }
+
+  /**
+   * Returns the commit ID as in the jar manifest, if {@linkplain 
#isReleaseBuild() build-time Git
+   * information} is available, when Polaris has been built with the Gradle 
{@code -Prelease}
+   * project property.
+   *
+   * <p>Example value: {@code d417725ec7c88c1ee8f940ffb2ce72aec7fb2a17}
+   *
+   * @see #isReleaseBuild()
+   */
+  public static Optional<String> getBuildGitHead() {
+    return PolarisVersionJarInfo.buildInfo(MF_BUILD_GIT_HEAD);
+  }
+
+  /**
+   * Returns the output of {@code git describe --tags} as in the jar manifest, 
if {@linkplain
+   * #isReleaseBuild() build-time Git information} is available, when Polaris 
has been built with
+   * the Gradle {@code -Prelease} project property.
+   *
+   * <p>Example value: {@code apache-polaris-0.1.2-incubating}
+   *
+   * @see #isReleaseBuild()
+   */
+  public static Optional<String> getBuildGitTag() {
+    return PolarisVersionJarInfo.buildInfo(MF_BUILD_GIT_DESCRIBE);
+  }
+
+  /**
+   * Returns the Java version used during the build as in the jar manifest, if 
{@linkplain
+   * #isReleaseBuild() build-time Git information} is available, when Polaris 
has been built with
+   * the Gradle {@code -Prelease} project property.
+   *
+   * <p>Example value: {@code 21.0.5}
+   *
+   * @see #isReleaseBuild()
+   */
+  public static Optional<String> getBuildJavaVersion() {
+    return PolarisVersionJarInfo.buildInfo(MF_BUILD_JAVA_VERSION);
+  }
+
+  /**
+   * Returns information about the system that performed the build, if 
{@linkplain #isReleaseBuild()
+   * build-time Git information} is available, when Polaris has been built 
with the Gradle {@code
+   * -Prelease} project property.
+   *
+   * <p>Example value: {@code 21.0.5}

Review Comment:
   copy-paste-magic



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to