Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,21 @@
*/
public static String getVersion() {
if (version.isEmpty()) {
try (InputStream is = Version.class.getResourceAsStream("/version.txt")) {
byte[] buf = new byte[64];
int len = is.read(buf);
version = new String(buf, 0, len);
try {
InputStream is = Version.class.getResourceAsStream("/version.txt");

Check warning on line 35 in hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/util/Version.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/util/Version.java#L35

Added line #L35 was not covered by tests
if (is != null) {
try (is) {
byte[] buf = new byte[64];
int len = is.read(buf);
version = new String(buf, 0, len);

Check warning on line 40 in hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/util/Version.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/util/Version.java#L37-L40

Added lines #L37 - L40 were not covered by tests
}
} else {
// 如果找不到version.txt文件,设置一个默认值
version = "unknown";
log.warn("Cannot find version.txt resource file, using default version: {}", version);

Check warning on line 45 in hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/util/Version.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/util/Version.java#L44-L45

Added lines #L44 - L45 were not covered by tests
}
} catch (Exception e) {
version = "unknown";

Check warning on line 48 in hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/util/Version.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/util/Version.java#L48

Added line #L48 was not covered by tests
log.error("Version.getVersion exception: ", e);
}
}
Expand Down
53 changes: 53 additions & 0 deletions hugegraph-store/hg-store-node/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand All @@ -171,6 +177,53 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>generate-version-file</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources-filtered</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>generate-version-txt</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<mkdir dir="${project.build.directory}/classes"/>
<echo file="${project.build.directory}/classes/version.txt">${project.version}</echo>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Loading