diff --git a/hugegraph-commons/hugegraph-common/pom.xml b/hugegraph-commons/hugegraph-common/pom.xml index 4c84b30c99..a57bcf59cd 100644 --- a/hugegraph-commons/hugegraph-common/pom.xml +++ b/hugegraph-commons/hugegraph-common/pom.xml @@ -238,6 +238,12 @@ + + + src/main/resources + true + + org.apache.maven.plugins diff --git a/hugegraph-commons/hugegraph-common/src/main/java/org/apache/hugegraph/util/VersionUtil.java b/hugegraph-commons/hugegraph-common/src/main/java/org/apache/hugegraph/util/VersionUtil.java index b49adda87a..545d27dc60 100644 --- a/hugegraph-commons/hugegraph-common/src/main/java/org/apache/hugegraph/util/VersionUtil.java +++ b/hugegraph-commons/hugegraph-common/src/main/java/org/apache/hugegraph/util/VersionUtil.java @@ -19,9 +19,11 @@ import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.Objects; +import java.util.Properties; import java.util.jar.Attributes; import java.util.jar.Manifest; @@ -233,4 +235,16 @@ public String toString() { return this.version; } } + + public static String getVersionNumber() { + final Properties PROPS = new Properties(); + + try (InputStream is = + VersionUtil.class.getResourceAsStream("/version.properties")) { + PROPS.load(is); + } catch (IOException e) { + throw new RuntimeException("Could not load version.properties", e); + } + return PROPS.getProperty("version"); + } } diff --git a/hugegraph-commons/hugegraph-common/src/main/java/org/apache/hugegraph/version/CommonVersion.java b/hugegraph-commons/hugegraph-common/src/main/java/org/apache/hugegraph/version/CommonVersion.java index 73342fdaaa..397264d4fa 100644 --- a/hugegraph-commons/hugegraph-common/src/main/java/org/apache/hugegraph/version/CommonVersion.java +++ b/hugegraph-commons/hugegraph-common/src/main/java/org/apache/hugegraph/version/CommonVersion.java @@ -17,12 +17,15 @@ package org.apache.hugegraph.version; -import org.apache.hugegraph.util.VersionUtil.Version; +import org.apache.hugegraph.util.VersionUtil; + public class CommonVersion { public static final String NAME = "hugegraph-common"; // The second parameter of Version.of() is for all-in-one JAR - public static final Version VERSION = Version.of(CommonVersion.class, "1.5.0"); + public static final VersionUtil.Version + VERSION = VersionUtil.Version.of(CommonVersion.class, VersionUtil.getVersionNumber()); + } diff --git a/hugegraph-commons/hugegraph-common/src/main/resources/version.properties b/hugegraph-commons/hugegraph-common/src/main/resources/version.properties new file mode 100644 index 0000000000..45c932a056 --- /dev/null +++ b/hugegraph-commons/hugegraph-common/src/main/resources/version.properties @@ -0,0 +1,16 @@ +# 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. + +version=${revision} diff --git a/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/version/RpcVersion.java b/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/version/RpcVersion.java index a2dd3d72c1..5e407b1125 100644 --- a/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/version/RpcVersion.java +++ b/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/version/RpcVersion.java @@ -17,12 +17,13 @@ package org.apache.hugegraph.version; -import org.apache.hugegraph.util.VersionUtil.Version; +import org.apache.hugegraph.util.VersionUtil; public class RpcVersion { public static final String NAME = "hugegraph-rpc"; // The second parameter of Version.of() is for all-in-one JAR - public static final Version VERSION = Version.of(RpcVersion.class, "1.5.0"); + public static final VersionUtil.Version VERSION = VersionUtil.Version.of( + RpcVersion.class, VersionUtil.getVersionNumber()); } diff --git a/hugegraph-pd/hg-pd-service/pom.xml b/hugegraph-pd/hg-pd-service/pom.xml index 37c90fe869..81b4568701 100644 --- a/hugegraph-pd/hg-pd-service/pom.xml +++ b/hugegraph-pd/hg-pd-service/pom.xml @@ -124,7 +124,7 @@ org.apache.hugegraph hugegraph-common - 1.2.0 + ${hugegraph-commons.version} org.apache.logging.log4j diff --git a/hugegraph-pd/hg-pd-service/src/main/java/org/apache/hugegraph/pd/rest/API.java b/hugegraph-pd/hg-pd-service/src/main/java/org/apache/hugegraph/pd/rest/API.java index a2287cb83e..d55ec36480 100644 --- a/hugegraph-pd/hg-pd-service/src/main/java/org/apache/hugegraph/pd/rest/API.java +++ b/hugegraph-pd/hg-pd-service/src/main/java/org/apache/hugegraph/pd/rest/API.java @@ -29,11 +29,13 @@ import com.google.protobuf.MessageOrBuilder; import com.google.protobuf.util.JsonFormat; +import org.apache.hugegraph.util.VersionUtil; + public class API { // TODO: use a flexible way to define the version // refer: https://github.com/apache/hugegraph/pull/2528#discussion_r1573823996 - public static final String VERSION = "1.5.0"; + public static final String VERSION = VersionUtil.getVersionNumber(); public static final String PD = "PD"; public static final String STORE = "STORE"; public static String STATUS_KEY = "status"; diff --git a/hugegraph-server/hugegraph-dist/src/assembly/travis/start-pd.sh b/hugegraph-server/hugegraph-dist/src/assembly/travis/start-pd.sh index 9f694d5c3c..4c02280eeb 100755 --- a/hugegraph-server/hugegraph-dist/src/assembly/travis/start-pd.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/travis/start-pd.sh @@ -18,7 +18,8 @@ set -ev HOME_DIR=$(pwd) -PD_DIR=$HOME_DIR/hugegraph-pd/apache-hugegraph-pd-incubating-1.5.0 +source $HOME_DIR/hugegraph-commons/hugegraph-common/src/main/resources/version.properties +PD_DIR=$HOME_DIR/hugegraph-pd/apache-hugegraph-pd-incubating-${version} pushd $PD_DIR . bin/start-hugegraph-pd.sh diff --git a/hugegraph-server/hugegraph-dist/src/assembly/travis/start-store.sh b/hugegraph-server/hugegraph-dist/src/assembly/travis/start-store.sh index 23e8f2297c..fe202101b5 100755 --- a/hugegraph-server/hugegraph-dist/src/assembly/travis/start-store.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/travis/start-store.sh @@ -18,7 +18,9 @@ set -ev HOME_DIR=$(pwd) -STORE_DIR=$HOME_DIR/hugegraph-store/apache-hugegraph-store-incubating-1.5.0 + +source $HOME_DIR/hugegraph-commons/hugegraph-common/src/main/resources/version.properties +STORE_DIR=$HOME_DIR/hugegraph-store/apache-hugegraph-store-incubating-${version} pushd $STORE_DIR . bin/start-hugegraph-store.sh