You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/07/05 16:40:39 UTC

[GitHub] [iceberg] rdblue commented on a diff in pull request #5186: [WIP] [Build/Core] - Add a Gradle task to create a build properties file for core module and accessor class

rdblue commented on code in PR #5186:
URL: https://github.com/apache/iceberg/pull/5186#discussion_r913995815


##########
core/src/main/java/org/apache/iceberg/util/VersionPropertiesUtil.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.iceberg.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+import org.apache.iceberg.relocated.com.google.common.io.Resources;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Loads the version.properties file with build information for project iceberg-core.
+ */
+public class VersionPropertiesUtil {
+
+  private VersionPropertiesUtil() {
+  }
+
+  private static final Logger LOG = LoggerFactory.getLogger(VersionPropertiesUtil.class);
+  private static final String VERSION_PROPERTIES_FILE = "version.properties";
+
+  private static boolean isLoaded = false;
+  private static Properties versionProperties = new Properties();
+
+  private static String gitHash;  // 10 character short git hash of the build
+  private static String gitHashFull;  // 40 character full git hash of the build
+  private static String projectName;
+  private static String projectVersion;
+
+  /**
+   * Loads the version.properties file for this module.
+   */
+  public static void loadBuildInfo() {
+    InputStream inputStream = null;
+
+    try {
+      inputStream = readResource(VERSION_PROPERTIES_FILE);

Review Comment:
   This should use a try-with-resources block to ensure that it is closed.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org