carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jack...@apache.org
Subject [22/50] [abbrv] carbondata git commit: [CARBONDATA-1932]Add version info for CarbonData
Date Sun, 07 Jan 2018 03:05:30 GMT
[CARBONDATA-1932]Add version info for CarbonData

Add version info for CarbonData.
The way of generating version info is the same as spark.

This closed #1738


Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/1799642b
Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/1799642b
Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/1799642b

Branch: refs/heads/carbonstore
Commit: 1799642b1eed187c810d32a358777b76a167c8b2
Parents: a774202
Author: Zhang Zhichao <441586683@qq.com>
Authored: Thu Dec 28 23:41:46 2017 +0800
Committer: Jacky Li <jacky.likun@qq.com>
Committed: Wed Jan 3 15:28:54 2018 +0800

----------------------------------------------------------------------
 build/carbondata-build-info                     | 36 +++++++++
 core/pom.xml                                    | 28 +++++++
 .../core/constants/CarbonVersionConstants.java  | 77 ++++++++++++++++++++
 .../constants/CarbondataVersionUnitTest.java    | 34 +++++++++
 4 files changed, 175 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/1799642b/build/carbondata-build-info
----------------------------------------------------------------------
diff --git a/build/carbondata-build-info b/build/carbondata-build-info
new file mode 100755
index 0000000..0d619fc
--- /dev/null
+++ b/build/carbondata-build-info
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+#
+# 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.
+#
+
+# This script generates the build info for carbondata and places it into the carbondata-version-info.properties
file.
+# Arguments:
+#   build_tgt_directory - The target directory where properties file would be created. [./core/target/extra-resources]
+#   carbondata_version - The current version of carbondata 
+
+RESOURCE_DIR="$1"
+mkdir -p "$RESOURCE_DIR"
+CARBONDATA_BUILD_INFO="${RESOURCE_DIR}"/carbondata-version-info.properties
+
+echo_build_properties() {
+  echo version=$1
+  echo revision=$(git rev-parse HEAD)
+  echo branch=$(git rev-parse --abbrev-ref HEAD)
+  echo date=$(date -u +%Y-%m-%dT%H:%M:%SZ)
+}
+
+echo_build_properties $2 > "$CARBONDATA_BUILD_INFO"

http://git-wip-us.apache.org/repos/asf/carbondata/blob/1799642b/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 50e6a6d..ebcf0ee 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -106,9 +106,37 @@
           <include>CARBON_CORELogResource.properties</include>
         </includes>
       </resource>
+      <resource>
+        <!-- Include the properties file to provide the build information. -->
+        <directory>${project.build.directory}/extra-resources</directory>
+        <filtering>true</filtering>
+      </resource>
     </resources>
     <plugins>
       <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <version>1.8</version>
+        <executions>
+          <execution>
+            <phase>generate-resources</phase>
+            <configuration>
+              <!-- Execute the shell script to generate the CarbonData build information.
-->
+              <target>
+                <exec executable="bash">
+                  <arg value="${project.basedir}/../build/carbondata-build-info"/>
+                  <arg value="${project.build.directory}/extra-resources"/>
+                  <arg value="${project.version}"/>
+                </exec>
+              </target>
+            </configuration>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
           <source>1.7</source>

http://git-wip-us.apache.org/repos/asf/carbondata/blob/1799642b/core/src/main/java/org/apache/carbondata/core/constants/CarbonVersionConstants.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/constants/CarbonVersionConstants.java
b/core/src/main/java/org/apache/carbondata/core/constants/CarbonVersionConstants.java
new file mode 100644
index 0000000..2d58b0b
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/constants/CarbonVersionConstants.java
@@ -0,0 +1,77 @@
+/*
+ * 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.carbondata.core.constants;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.carbondata.common.logging.LogService;
+import org.apache.carbondata.common.logging.LogServiceFactory;
+
+public final class CarbonVersionConstants {
+
+  private static final LogService LOGGER =
+      LogServiceFactory.getLogService(CarbonVersionConstants.class.getName());
+  /**
+   * the file name of CarbonData version info
+   */
+  private static final String CARBONDATA_VERSION_INFO_FILE =
+      "carbondata-version-info.properties";
+  /**
+   * current CarbonData version
+   */
+  public static final String CARBONDATA_VERSION;
+  /**
+   * which branch current version build from
+   */
+  public static final String CARBONDATA_BRANCH;
+  /**
+   * the latest commit revision which current branch point to
+   */
+  public static final String CARBONDATA_REVISION;
+  /**
+   * the date of building current version
+   */
+  public static final String CARBONDATA_BUILD_DATE;
+
+  static {
+    // create input stream for CARBONDATA_VERSION_INFO_FILE
+    InputStream resourceStream = Thread.currentThread().getContextClassLoader()
+        .getResourceAsStream(CARBONDATA_VERSION_INFO_FILE);
+    Properties props = new Properties();
+    try {
+      // read CARBONDATA_VERSION_INFO_FILE into props
+      props.load(resourceStream);
+    } catch (Exception e) {
+      LOGGER.error(e, "Error loading properties from " + CARBONDATA_VERSION_INFO_FILE);
+    } finally {
+      if (resourceStream != null) {
+        try {
+          resourceStream.close();
+        } catch (Exception e) {
+          LOGGER.error(e, "Error closing CarbonData build info resource stream");
+        }
+      }
+    }
+    // set the values
+    CARBONDATA_VERSION = props.getProperty("version");
+    CARBONDATA_BRANCH = props.getProperty("branch");
+    CARBONDATA_REVISION = props.getProperty("revision");
+    CARBONDATA_BUILD_DATE = props.getProperty("date");
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/1799642b/core/src/test/java/org/apache/carbondata/core/constants/CarbondataVersionUnitTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/constants/CarbondataVersionUnitTest.java
b/core/src/test/java/org/apache/carbondata/core/constants/CarbondataVersionUnitTest.java
new file mode 100644
index 0000000..52dbf07
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/constants/CarbondataVersionUnitTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.carbondata.core.constants;
+
+import org.apache.carbondata.core.constants.CarbonVersionConstants;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertTrue;
+
+public class CarbondataVersionUnitTest {
+
+  @Test public void testCarbonVersionNotNull() {
+    assertTrue(StringUtils.isNoneEmpty(CarbonVersionConstants.CARBONDATA_VERSION));
+    assertTrue(StringUtils.isNoneEmpty(CarbonVersionConstants.CARBONDATA_BRANCH));
+    assertTrue(StringUtils.isNoneEmpty(CarbonVersionConstants.CARBONDATA_REVISION));
+    assertTrue(StringUtils.isNoneEmpty(CarbonVersionConstants.CARBONDATA_BUILD_DATE));
+  }
+}


Mime
View raw message