You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dp...@apache.org on 2019/01/28 11:42:45 UTC

[ignite] branch master updated: IGNITE-11084 copyrights date now depend on build date. (#5930)

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

dpavlov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 01a5a91  IGNITE-11084 copyrights date now depend on build date. (#5930)
01a5a91 is described below

commit 01a5a915c3eaa87b5a2df153a44d19b78ea454c8
Author: Andrey Aleksandrov <37...@users.noreply.github.com>
AuthorDate: Mon Jan 28 14:42:33 2019 +0300

    IGNITE-11084 copyrights date now depend on build date. (#5930)
---
 .../apache/ignite/internal/IgniteVersionUtils.java | 15 ++++++--
 .../internal/IgniteVersionUtilsSelfTest.java       | 41 ++++++++++++++++++++++
 .../ignite/testsuites/IgniteUtilSelfTestSuite.java |  2 ++
 3 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteVersionUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteVersionUtils.java
index 8a45952..d12560e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteVersionUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteVersionUtils.java
@@ -37,6 +37,9 @@ public class IgniteVersionUtils {
     /** Build timestamp in seconds. */
     public static final long BUILD_TSTAMP;
 
+    /** Build timestamp string property value. */
+    private static final String BUILD_TSTAMP_FROM_PROPERTY;
+
     /** Revision hash. */
     public static final String REV_HASH_STR;
 
@@ -47,7 +50,7 @@ public class IgniteVersionUtils {
     public static final String ACK_VER_STR;
 
     /** Copyright blurb. */
-    public static final String COPYRIGHT = "2018 Copyright(C) Apache Software Foundation";
+    public static final String COPYRIGHT;
 
     /**
      * Static initializer.
@@ -58,10 +61,18 @@ public class IgniteVersionUtils {
             .replace(".b", "-b")
             .replace(".final", "-final");
 
-        BUILD_TSTAMP = Long.valueOf(IgniteProperties.get("ignite.build"));
+        BUILD_TSTAMP_FROM_PROPERTY = IgniteProperties.get("ignite.build");
+
+        //Development ignite.properties file contains ignite.build = 0, so we will add the check for it.
+        BUILD_TSTAMP = !BUILD_TSTAMP_FROM_PROPERTY.isEmpty() && Long.parseLong(BUILD_TSTAMP_FROM_PROPERTY) != 0
+            ? Long.parseLong(BUILD_TSTAMP_FROM_PROPERTY) : System.currentTimeMillis() / 1000;
+
         BUILD_TSTAMP_STR = new SimpleDateFormat("yyyyMMdd").format(new Date(BUILD_TSTAMP * 1000));
 
+        COPYRIGHT = BUILD_TSTAMP_STR.substring(0, 4) + " Copyright(C) Apache Software Foundation";
+
         REV_HASH_STR = IgniteProperties.get("ignite.revision");
+
         RELEASE_DATE_STR = IgniteProperties.get("ignite.rel.date");
 
         String rev = REV_HASH_STR.length() > 8 ? REV_HASH_STR.substring(0, 8) : REV_HASH_STR;
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteVersionUtilsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteVersionUtilsSelfTest.java
new file mode 100644
index 0000000..95624de
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteVersionUtilsSelfTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.ignite.internal;
+
+import java.util.Calendar;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ */
+@RunWith(JUnit4.class)
+public class IgniteVersionUtilsSelfTest extends GridCommonAbstractTest {
+    /**
+     * @throws Exception If failed.
+     */
+    @Test
+    public void testIgniteCopyrights() throws Exception {
+        final String COPYRIGHT = String.valueOf(Calendar.getInstance().get(Calendar.YEAR)) + " Copyright(C) Apache Software Foundation";
+
+        assertNotNull(IgniteVersionUtils.COPYRIGHT);
+
+        assertTrue(COPYRIGHT.equals(IgniteVersionUtils.COPYRIGHT));
+    }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java
index 3176057..d444132 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteUtilSelfTestSuite.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.testsuites;
 
+import org.apache.ignite.internal.IgniteVersionUtilsSelfTest;
 import org.apache.ignite.internal.commandline.CommandHandlerParsingTest;
 import org.apache.ignite.internal.pagemem.impl.PageIdUtilsSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheUtilsSelfTest;
@@ -70,6 +71,7 @@ import org.junit.runners.Suite;
     GridThreadPoolExecutorServiceSelfTest.class,
     IgniteThreadPoolSizeTest.class,
     IgniteUtilsSelfTest.class,
+    IgniteVersionUtilsSelfTest.class,
     GridSpinReadWriteLockSelfTest.class,
     GridQueueSelfTest.class,
     GridStringBuilderFactorySelfTest.class,