prashantwason commented on code in PR #17466:
URL: https://github.com/apache/hudi/pull/17466#discussion_r2730449217


##########
hudi-common/src/main/java/org/apache/hudi/HoodieVersion.java:
##########
@@ -0,0 +1,143 @@
+/*
+ * 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.hudi;
+
+import org.apache.hudi.common.util.StringUtils;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Exposes the semantic versioning (https://semver.org/) of HUDI code.
+ *
+ * HUDI versions are configured through maven and are formatted as 
<major>.<minor>.<patch>. Example: 0.12.2 or 0.12.3-snapshot
+ */
+public final class HoodieVersion {
+  private static String HOODIE_DEFAULT_VERSION = "0.14.x";
+
+  public static final String HOODIE_WRITER_VERSION = "hudi_writer_version";
+
+  /**
+   * Returns the complete version of HUDI code
+   * Example: 0.12.2 or 0.12.3-snapshot
+   */
+  public static String get() {
+    String hudiPropertiesFilePath = 
"META-INF/maven/org.apache.hudi/hudi-common/pom.properties";
+    try (InputStream inputStream = 
HoodieVersion.class.getClassLoader().getResourceAsStream(hudiPropertiesFilePath))
 {
+      Properties properties = new Properties();
+      if (inputStream != null) {
+        properties.load(inputStream);
+        // Access properties
+        return properties.getProperty("version");
+      }
+    } catch (Exception ignored) {
+      // Ignoring the exception as there is as fallback to default version
+    }
+    return HOODIE_DEFAULT_VERSION;
+  }
+
+  /**
+   * Returns the major version of HUDI code
+   * Example: 0 for 0.12.2
+   */
+  public static String major() {
+    return getVersion(1);
+  }
+
+  /**
+   * Returns the minor version of HUDI code
+   * Example: 0.12 for 0.12.2
+   */
+  public static String minor() {
+    return getVersion(2);
+  }
+
+  /**
+   * Returns the patch version of HUDI code
+   * Example: 0.12.2 for 0.12.2, 0.12.3-SNAPSHOT for 0.12.3-SNAPSHOT
+   */
+  public static String patch() {
+    return getVersion(3);
+  }
+
+  private static String getVersion(int allowedDotCount) {
+    return getSubVersion(get(), allowedDotCount);
+  }
+
+  private static String getSubVersion(String version, int allowedDotCount) {
+    if (allowedDotCount == 1) {
+      int index = version.indexOf('.');
+      return index == -1 ? version : version.substring(0, index);
+    }
+    return getSubVersion(version.substring(version.indexOf('.') + 1), 
allowedDotCount - 1);
+  }
+
+  protected static void setVersionOverride(String version) {
+    HOODIE_DEFAULT_VERSION = version;
+  }
+
+  public static void main(String[] args) {

Review Comment:
   Removed.



##########
hudi-common/src/main/java/org/apache/hudi/HoodieVersion.java:
##########
@@ -0,0 +1,143 @@
+/*
+ * 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.hudi;
+
+import org.apache.hudi.common.util.StringUtils;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Exposes the semantic versioning (https://semver.org/) of HUDI code.
+ *
+ * HUDI versions are configured through maven and are formatted as 
<major>.<minor>.<patch>. Example: 0.12.2 or 0.12.3-snapshot
+ */
+public final class HoodieVersion {
+  private static String HOODIE_DEFAULT_VERSION = "0.14.x";

Review Comment:
   Updated to 1.2.3 to reflect the latest stable release version.



-- 
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