Skip to content

refactor: centralize version management in project#2797

Merged
VGalaxies merged 8 commits intoapache:masterfrom
koi2000:master
Jun 25, 2025
Merged

refactor: centralize version management in project#2797
VGalaxies merged 8 commits intoapache:masterfrom
koi2000:master

Conversation

@koi2000
Copy link
Contributor

@koi2000 koi2000 commented Jun 11, 2025

Improved version management by introducing Maven's property

Replaced hardcoded version strings with dynamic retrieval

Added version.properties to support runtime version access

Purpose of the PR

This PR centralizes version management across the project by leveraging Maven's ${revision} property and a filtered version.properties file for dynamic runtime access to the version. It removes the need for hardcoded version strings and ensures consistent versioning across all modules.

Summary With CN

  • 新功能
    • 引入 version.properties 文件,实现版本号和相关属性的集中配置,通过属性文件动态获取版本信息。
  • 功能优化
    • 多处组件(如 API、Core、RPC、PD 服务等)和启动脚本中的版本号由硬编码改为从属性文件动态读取,提升了版本管理的灵活性和一致性。
    • API 版本兼容性检查范围改为动态读取属性,便于后续维护。
    • API 文档配置改为程序化构建,增强了安全配置的灵活性。
  • 构建与依赖
    • Maven 配置优化,资源文件支持过滤,依赖版本号采用变量引用,便于统一管理和升级。
  • 脚本改进
    • 启动脚本根据属性文件动态加载版本号,避免手动修改脚本中的版本信息。

Main Changes

Replaced hardcoded version strings in classes like CommonVersion, RpcVersion, CoreVersion, and API.
Added a version.properties file with resource filtering for dynamic version retrieval.
Updated startup scripts (start-pd.sh, start-store.sh) to reflect the new version.
Remove the @OpenAPIDefinition annotation and specify the version in OpenAPI in the code instead.

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • Update the revision in Maven, rebuild the project, and check if the version matches.

Does this PR potentially affect the following parts?

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. ci-cd Build or deploy labels Jun 11, 2025
@imbajin imbajin requested a review from Copilot June 12, 2025 06:11

This comment was marked as outdated.

@imbajin imbajin changed the title centralize version management refactor: centralize version management in project Jun 12, 2025
@koi2000 koi2000 requested a review from Copilot June 12, 2025 07:01

This comment was marked as outdated.

HOME_DIR=$(pwd)
PD_DIR=$HOME_DIR/hugegraph-pd/apache-hugegraph-pd-incubating-1.5.0

PROPERTIES_FILE="$HOME_DIR/hugegraph-commons/hugegraph-common/src/main/resources/version.properties"
Copy link
Contributor

@VGalaxies VGalaxies Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By referencing the version.properties file in hugegraph-commons using a relative path, considering that start-pd.sh and start-store.sh are currently only used in the CI environment, maybe acceptable for now...

@imbajin What do you think?

Copy link
Member

@imbajin imbajin Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By referencing the version.properties file in hugegraph-commons using a relative path, considering that start-pd.sh and start-store.sh are currently only used in the CI environment, maybe acceptable for now...

@imbajin What do you think?

It seems so. We can make adjustments if we encounter any problems?

@VGalaxies
Copy link
Contributor

VGalaxies commented Jun 16, 2025

The version number in the pom.xml in the root directory of the project seems to have been forgotten? see https://github.com/apache/incubator-hugegraph/blob/master/pom.xml#L89

@koi2000
Copy link
Contributor Author

koi2000 commented Jun 16, 2025

The version number in the pom.xml in the root directory of the project seems to have been forgotten? see https://github.com/apache/incubator-hugegraph/blob/master/pom.xml#L89

Currently, version management mainly relies on the ${revision} variable in the flatten-maven-plugin. When updating the version, the ${revision} variable must be updated. The Version property in version.properties will be replaced with the ${revision} value from the POM file during compilation.
Additionally, when updating the version, it may also be necessary to update other fields in version.properties, such as ApiCheckBeginVersion and ApiCheckEndVersion, which are responsible for version validity checks. When hugegraph-commons is updated, the hugegraph-commons.version in the POM file may also need to be updated.

@VGalaxies
Copy link
Contributor

@koi2000 I would like to confirm if we upgrade the version of hugegraph to 1.9, we need to modify the following files:

diff --git a/hugegraph-commons/hugegraph-common/src/main/resources/version.properties b/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
index b413bf04e..1ef0cba5a 100644
--- a/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
+++ b/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
@@ -19,5 +19,5 @@
 Version=${revision}
 ApiVersion=0.71
 ApiCheckBeginVersion=1.0
-ApiCheckEndVersion=1.7
-VersionInBash=1.5.0
+ApiCheckEndVersion=2.0
+VersionInBash=1.9.0
diff --git a/hugegraph-commons/pom.xml b/hugegraph-commons/pom.xml
index 09cd71e5a..df3337dd1 100644
--- a/hugegraph-commons/pom.xml
+++ b/hugegraph-commons/pom.xml
@@ -90,7 +90,7 @@

     <properties>
         <!-- Note: We need also update the version in CommonVersion.java & RpcVersion.java now -->
-        <revision>1.5.0</revision>
+        <revision>1.9.0</revision>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <top.level.dir>${project.basedir}/..</top.level.dir>
         <compiler.source>1.8</compiler.source>
diff --git a/pom.xml b/pom.xml
index 1fa07660e..fa98ec7a4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,8 +86,8 @@
     </scm>

     <properties>
-        <revision>1.5.0</revision>
-        <hugegraph-commons.version>1.5.0</hugegraph-commons.version>
+        <revision>1.9.0</revision>
+        <hugegraph-commons.version>1.9.0</hugegraph-commons.version>
         <lombok.version>1.18.30</lombok.version>
         <release.name>hugegraph</release.name>
         <maven.compiler.source>11</maven.compiler.source>

if this aligns with the design expectations?

@koi2000
Copy link
Contributor Author

koi2000 commented Jun 16, 2025

@koi2000 I would like to confirm if we upgrade the version of hugegraph to 1.9, we need to modify the following files:

diff --git a/hugegraph-commons/hugegraph-common/src/main/resources/version.properties b/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
index b413bf04e..1ef0cba5a 100644
--- a/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
+++ b/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
@@ -19,5 +19,5 @@
 Version=${revision}
 ApiVersion=0.71
 ApiCheckBeginVersion=1.0
-ApiCheckEndVersion=1.7
-VersionInBash=1.5.0
+ApiCheckEndVersion=2.0
+VersionInBash=1.9.0
diff --git a/hugegraph-commons/pom.xml b/hugegraph-commons/pom.xml
index 09cd71e5a..df3337dd1 100644
--- a/hugegraph-commons/pom.xml
+++ b/hugegraph-commons/pom.xml
@@ -90,7 +90,7 @@

     <properties>
         <!-- Note: We need also update the version in CommonVersion.java & RpcVersion.java now -->
-        <revision>1.5.0</revision>
+        <revision>1.9.0</revision>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <top.level.dir>${project.basedir}/..</top.level.dir>
         <compiler.source>1.8</compiler.source>
diff --git a/pom.xml b/pom.xml
index 1fa07660e..fa98ec7a4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,8 +86,8 @@
     </scm>

     <properties>
-        <revision>1.5.0</revision>
-        <hugegraph-commons.version>1.5.0</hugegraph-commons.version>
+        <revision>1.9.0</revision>
+        <hugegraph-commons.version>1.9.0</hugegraph-commons.version>
         <lombok.version>1.18.30</lombok.version>
         <release.name>hugegraph</release.name>
         <maven.compiler.source>11</maven.compiler.source>

if this aligns with the design expectations?

You may also need to update the revision in the pom file under hugegraph-commons, or use a command similar to the following during the build: mvn package -DskipTests -Drevision=1.9.0 -ntp

In terms of design, I have only removed the hard-coded version information in the code. Perhaps it would be worth trying to move all version information into the POM file in the root directory for management. However, I have not found a suitable solution, as the fields in the compiled version.properties file cannot be read by start-pd.sh and start-store.sh. Therefore, the VersionInBash hard-coded value has been retained in version.properties.
Should I modify the current solution?

@VGalaxies
Copy link
Contributor

@koi2000 I would like to confirm if we upgrade the version of hugegraph to 1.9, we need to modify the following files:

diff --git a/hugegraph-commons/hugegraph-common/src/main/resources/version.properties b/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
index b413bf04e..1ef0cba5a 100644
--- a/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
+++ b/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
@@ -19,5 +19,5 @@
 Version=${revision}
 ApiVersion=0.71
 ApiCheckBeginVersion=1.0
-ApiCheckEndVersion=1.7
-VersionInBash=1.5.0
+ApiCheckEndVersion=2.0
+VersionInBash=1.9.0
diff --git a/hugegraph-commons/pom.xml b/hugegraph-commons/pom.xml
index 09cd71e5a..df3337dd1 100644
--- a/hugegraph-commons/pom.xml
+++ b/hugegraph-commons/pom.xml
@@ -90,7 +90,7 @@

     <properties>
         <!-- Note: We need also update the version in CommonVersion.java & RpcVersion.java now -->
-        <revision>1.5.0</revision>
+        <revision>1.9.0</revision>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <top.level.dir>${project.basedir}/..</top.level.dir>
         <compiler.source>1.8</compiler.source>
diff --git a/pom.xml b/pom.xml
index 1fa07660e..fa98ec7a4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,8 +86,8 @@
     </scm>

     <properties>
-        <revision>1.5.0</revision>
-        <hugegraph-commons.version>1.5.0</hugegraph-commons.version>
+        <revision>1.9.0</revision>
+        <hugegraph-commons.version>1.9.0</hugegraph-commons.version>
         <lombok.version>1.18.30</lombok.version>
         <release.name>hugegraph</release.name>
         <maven.compiler.source>11</maven.compiler.source>

if this aligns with the design expectations?

You may also need to update the revision in the pom file under hugegraph-commons, or use a command similar to the following during the build: mvn package -DskipTests -Drevision=1.9.0 -ntp

In terms of design, I have only removed the hard-coded version information in the code. Perhaps it would be worth trying to move all version information into the POM file in the root directory for management. However, I have not found a suitable solution, as the fields in the compiled version.properties file cannot be read by start-pd.sh and start-store.sh. Therefore, the VersionInBash hard-coded value has been retained in version.properties. Should I modify the current solution?

Fine, compared to before, the number of files that need to be modified has been greatly reduced. The current version upgrade cost is acceptable.

@imbajin, any suggestion?

VGalaxies
VGalaxies previously approved these changes Jun 16, 2025
@VGalaxies
Copy link
Contributor

@koi2000 could refer to the review suggestions in hugegraph#14

@koi2000 koi2000 requested a review from Copilot June 24, 2025 09:45

This comment was marked as outdated.

@koi2000 koi2000 requested a review from Copilot June 24, 2025 10:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR centralizes version management across the project by replacing hardcoded version strings with dynamic retrieval from a filtered properties file and Maven’s revision property.

  • Updated shell scripts (start-store.sh and start-pd.sh) to source version.properties for version management.
  • Modified Java classes (CoreVersion, ApiVersion, RpcVersion, CommonVersion, API) to use a centralized VersionUtil for version retrieval.
  • Added a version.properties file and updated pom.xml files to enable Maven resource filtering.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
hugegraph-server/hugegraph-dist/src/assembly/travis/start-store.sh Added logic to source version.properties and update directory path using version property.
hugegraph-server/hugegraph-dist/src/assembly/travis/start-pd.sh Similar to start-store.sh; sources version.properties and sets the PD directory.
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/version/CoreVersion.java Replaced hardcoded version with dynamic retrieval via VersionUtil.
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/version/ApiVersion.java Updated API version retrieval and check using VersionUtil methods.
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/server/ApplicationConfig.java Revised OpenAPI configuration using a dynamically retrieved version and restructured the OpenAPI setup.
hugegraph-pd/hg-pd-service/src/main/java/org/apache/hugegraph/pd/rest/API.java Updated version retrieval for the PD API.
hugegraph-pd/hg-pd-service/pom.xml Updated dependency version reference to use a Maven property.
hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/version/RpcVersion.java Replaced hardcoded version with VersionUtil in RPC module.
hugegraph-commons/hugegraph-common/src/main/resources/version.properties Added version.properties with version mappings and properties.
hugegraph-commons/hugegraph-common/src/main/java/org/apache/hugegraph/version/CommonVersion.java Updated common version retrieval using VersionUtil.
hugegraph-commons/hugegraph-common/src/main/java/org/apache/hugegraph/util/VersionUtil.java Introduced cached load for properties and added methods for API version support.
hugegraph-commons/hugegraph-common/pom.xml Enabled resource filtering for version.properties.

@koi2000
Copy link
Contributor Author

koi2000 commented Jun 24, 2025

@koi2000 could refer to the review suggestions in hugegraph#14

Completed

Comment on lines 35 to 36
// TODO: use a flexible way to define the version
// refer: https://github.com/apache/hugegraph/pull/2528#discussion_r1573823996
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it?

@imbajin
Copy link
Member

imbajin commented Jun 25, 2025

@koi2000 I would like to confirm if we upgrade the version of hugegraph to 1.9, we need to modify the following files:

diff --git a/hugegraph-commons/hugegraph-common/src/main/resources/version.properties b/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
index b413bf04e..1ef0cba5a 100644
--- a/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
+++ b/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
@@ -19,5 +19,5 @@
 Version=${revision}
 ApiVersion=0.71
 ApiCheckBeginVersion=1.0
-ApiCheckEndVersion=1.7
-VersionInBash=1.5.0
+ApiCheckEndVersion=2.0
+VersionInBash=1.9.0
diff --git a/hugegraph-commons/pom.xml b/hugegraph-commons/pom.xml
index 09cd71e5a..df3337dd1 100644
--- a/hugegraph-commons/pom.xml
+++ b/hugegraph-commons/pom.xml
@@ -90,7 +90,7 @@

     <properties>
         <!-- Note: We need also update the version in CommonVersion.java & RpcVersion.java now -->
-        <revision>1.5.0</revision>
+        <revision>1.9.0</revision>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <top.level.dir>${project.basedir}/..</top.level.dir>
         <compiler.source>1.8</compiler.source>
diff --git a/pom.xml b/pom.xml
index 1fa07660e..fa98ec7a4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,8 +86,8 @@
     </scm>

     <properties>
-        <revision>1.5.0</revision>
-        <hugegraph-commons.version>1.5.0</hugegraph-commons.version>
+        <revision>1.9.0</revision>
+        <hugegraph-commons.version>1.9.0</hugegraph-commons.version>
         <lombok.version>1.18.30</lombok.version>
         <release.name>hugegraph</release.name>
         <maven.compiler.source>11</maven.compiler.source>

if this aligns with the design expectations?

You may also need to update the revision in the pom file under hugegraph-commons, or use a command similar to the following during the build: mvn package -DskipTests -Drevision=1.9.0 -ntp

In terms of design, I have only removed the hard-coded version information in the code. Perhaps it would be worth trying to move all version information into the POM file in the root directory for management. However, I have not found a suitable solution, as the fields in the compiled version.properties file cannot be read by start-pd.sh and start-store.sh. Therefore, the VersionInBash hard-coded value has been retained in version.properties. Should I modify the current solution?

@koi2000 maybe we need add a basic doc for it? (How could other devs modify the version if they need)

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 25, 2025
@VGalaxies VGalaxies merged commit e139465 into apache:master Jun 25, 2025
12 of 13 checks passed
@koi2000
Copy link
Contributor Author

koi2000 commented Jun 25, 2025

@koi2000 I would like to confirm if we upgrade the version of hugegraph to 1.9, we need to modify the following files:

diff --git a/hugegraph-commons/hugegraph-common/src/main/resources/version.properties b/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
index b413bf04e..1ef0cba5a 100644
--- a/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
+++ b/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
@@ -19,5 +19,5 @@
 Version=${revision}
 ApiVersion=0.71
 ApiCheckBeginVersion=1.0
-ApiCheckEndVersion=1.7
-VersionInBash=1.5.0
+ApiCheckEndVersion=2.0
+VersionInBash=1.9.0
diff --git a/hugegraph-commons/pom.xml b/hugegraph-commons/pom.xml
index 09cd71e5a..df3337dd1 100644
--- a/hugegraph-commons/pom.xml
+++ b/hugegraph-commons/pom.xml
@@ -90,7 +90,7 @@

     <properties>
         <!-- Note: We need also update the version in CommonVersion.java & RpcVersion.java now -->
-        <revision>1.5.0</revision>
+        <revision>1.9.0</revision>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <top.level.dir>${project.basedir}/..</top.level.dir>
         <compiler.source>1.8</compiler.source>
diff --git a/pom.xml b/pom.xml
index 1fa07660e..fa98ec7a4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,8 +86,8 @@
     </scm>

     <properties>
-        <revision>1.5.0</revision>
-        <hugegraph-commons.version>1.5.0</hugegraph-commons.version>
+        <revision>1.9.0</revision>
+        <hugegraph-commons.version>1.9.0</hugegraph-commons.version>
         <lombok.version>1.18.30</lombok.version>
         <release.name>hugegraph</release.name>
         <maven.compiler.source>11</maven.compiler.source>

if this aligns with the design expectations?

You may also need to update the revision in the pom file under hugegraph-commons, or use a command similar to the following during the build: mvn package -DskipTests -Drevision=1.9.0 -ntp
In terms of design, I have only removed the hard-coded version information in the code. Perhaps it would be worth trying to move all version information into the POM file in the root directory for management. However, I have not found a suitable solution, as the fields in the compiled version.properties file cannot be read by start-pd.sh and start-store.sh. Therefore, the VersionInBash hard-coded value has been retained in version.properties. Should I modify the current solution?

@koi2000 maybe we need add a basic doc for it? (How could other devs modify the version if they need)

Is the repository corresponding to the documentation incubator-hugegraph-doc? I will open a PR in the documentation repository later.

@VGalaxies
Copy link
Contributor

Is the repository corresponding to the documentation incubator-hugegraph-doc? I will open a PR in the documentation repository later.

Yes, that's correct. However, it seems we currently don't have a suitable page to add this content. Perhaps it could go on https://hugegraph.apache.org/docs/contribution-guidelines/validate-release/ @imbajin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-cd Build or deploy lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce the number of files that need to be changed during version upgrades

4 participants