refactor: centralize version management in project#2797
refactor: centralize version management in project#2797VGalaxies merged 8 commits intoapache:masterfrom
Conversation
| 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" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
By referencing the
version.propertiesfile inhugegraph-commonsusing a relative path, considering thatstart-pd.shandstart-store.share 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?
|
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. |
|
@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. |
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? |
...graph-commons/hugegraph-common/src/main/java/org/apache/hugegraph/version/CommonVersion.java
Outdated
Show resolved
Hide resolved
|
@koi2000 could refer to the review suggestions in hugegraph#14 |
There was a problem hiding this comment.
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. |
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/server/ApplicationConfig.java
Show resolved
Hide resolved
Completed |
| // TODO: use a flexible way to define the version | ||
| // refer: https://github.com/apache/hugegraph/pull/2528#discussion_r1573823996 |
@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. |
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? |
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
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
Does this PR potentially affect the following parts?
Documentation Status
Doc - TODODoc - DoneDoc - No Need