diff --git a/pom.xml b/pom.xml index 864480e41..e2ca47893 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.baidu.hugegraph hugegraph-common - 1.5.3 + 1.5.4 hugegraph-common https://github.com/hugegraph/hugegraph-common @@ -67,6 +67,7 @@ 3.0.1 3.21.0-GA 2.25.1 + 2.27 4.12 @@ -155,6 +156,11 @@ jersey-media-json-jackson ${jersey.version} + + org.glassfish.jersey.inject + jersey-hk2 + ${jersey.hk2.version} + @@ -192,7 +198,7 @@ - 1.5.3.0 + 1.5.4.0 diff --git a/src/main/java/com/baidu/hugegraph/version/CommonVersion.java b/src/main/java/com/baidu/hugegraph/version/CommonVersion.java index deb96e040..aa9c14f7c 100644 --- a/src/main/java/com/baidu/hugegraph/version/CommonVersion.java +++ b/src/main/java/com/baidu/hugegraph/version/CommonVersion.java @@ -25,5 +25,7 @@ public class CommonVersion { public static final String NAME = "hugegraph-common"; - public static final Version VERSION = Version.of(CommonVersion.class); + // The second parameter of Version.of() is for all-in-one JAR + public static final Version VERSION = Version.of(CommonVersion.class, + "1.5.4"); } diff --git a/src/test/java/com/baidu/hugegraph/unit/version/VersionTest.java b/src/test/java/com/baidu/hugegraph/unit/version/VersionTest.java new file mode 100644 index 000000000..76bbb7db2 --- /dev/null +++ b/src/test/java/com/baidu/hugegraph/unit/version/VersionTest.java @@ -0,0 +1,74 @@ +/* + * Copyright 2017 HugeGraph Authors + * + * 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 com.baidu.hugegraph.unit.version; + +import java.io.BufferedReader; +import java.io.Closeable; +import java.io.InputStreamReader; + +import org.junit.Test; + +import com.baidu.hugegraph.testutil.Assert; +import com.baidu.hugegraph.version.CommonVersion; + +public class VersionTest { + + @Test + public void testGetCommonVersion() { + String version = CommonVersion.VERSION.get(); + Assert.assertNotNull(version); + String pomVersion = readVersionFromPom(); + Assert.assertEquals(version, pomVersion); + } + + private static String readVersionFromPom() { + String cmd = "cat \"pom.xml\" | grep \"\" | head -1 | " + + "awk -F '<|>' '{print $3}'"; + + Process process = null; + InputStreamReader isr = null; + try { + String[] commond = {"/bin/sh", "-c", cmd}; + process = Runtime.getRuntime().exec(commond); + process.waitFor(); + + isr = new InputStreamReader(process.getInputStream()); + BufferedReader br = new BufferedReader(isr); + return br.readLine(); + } catch (Exception e) { + throw new RuntimeException(e); + } finally { + closeStream(isr); + // Destroy child process + if (process != null) { + process.destroy(); + } + } + } + + private static void closeStream(Closeable stream) { + if (stream != null) { + try { + stream.close(); + } catch (Exception ignored) { + } + } + } +}