Skip to content

Commit cdbfc64

Browse files
gosonzhangvernedeng
authored andcommitted
[INLONG-11861][CI] Compile dataproxy-sdk fail when there is no .git dictionary in the base path (#11862)
(cherry picked from commit 12c2998)
1 parent 96e2829 commit cdbfc64

File tree

5 files changed

+31
-26
lines changed

5 files changed

+31
-26
lines changed

.licenserc.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,7 @@ header:
9393
- '**/tubemq-client-go/go.sum'
9494
- '**/dataproxy-sdk-golang/go.sum'
9595

96+
# dataproxy sdk version
97+
- '**/resources/sdk.version'
98+
9699
comment: on-failure

inlong-sdk/dataproxy-sdk/pom.xml

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,20 @@
117117
</dependencies>
118118

119119
<build>
120+
<resources>
121+
<resource>
122+
<filtering>true</filtering>
123+
<directory>src/main/resources</directory>
124+
</resource>
125+
</resources>
120126
<plugins>
127+
<plugin>
128+
<groupId>org.apache.maven.plugins</groupId>
129+
<artifactId>maven-resources-plugin</artifactId>
130+
<configuration>
131+
<encoding>UTF-8</encoding>
132+
</configuration>
133+
</plugin>
121134
<plugin>
122135
<groupId>org.apache.maven.plugins</groupId>
123136
<artifactId>maven-compiler-plugin</artifactId>
@@ -174,28 +187,6 @@
174187
</execution>
175188
</executions>
176189
</plugin>
177-
<plugin>
178-
<groupId>io.github.git-commit-id</groupId>
179-
<artifactId>git-commit-id-maven-plugin</artifactId>
180-
<version>4.9.9</version>
181-
<configuration>
182-
<generateGitPropertiesFile>true</generateGitPropertiesFile>
183-
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
184-
<includeOnlyProperties>
185-
<includeOnlyProperty>^git.build.(version)$</includeOnlyProperty>
186-
</includeOnlyProperties>
187-
<commitIdGenerationMode>full</commitIdGenerationMode>
188-
</configuration>
189-
<executions>
190-
<execution>
191-
<id>get-the-git-infos</id>
192-
<goals>
193-
<goal>revision</goal>
194-
</goals>
195-
<phase>initialize</phase>
196-
</execution>
197-
</executions>
198-
</plugin>
199190
</plugins>
200191
</build>
201192

inlong-sdk/dataproxy-sdk/src/main/java/org/apache/inlong/sdk/dataproxy/utils/ProxyUtils.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,19 @@ public static String getJarVersion() {
104104
if (sdkVersion != null) {
105105
return sdkVersion;
106106
}
107-
Properties properties = new Properties();
108-
try (InputStream is = ProxyUtils.class.getResourceAsStream("/git.properties")) {
109-
properties.load(is);
110-
sdkVersion = properties.getProperty("git.build.version");
107+
try (InputStream is = ProxyUtils.class.getClassLoader().getResourceAsStream("sdk.version")) {
108+
if (is == null) {
109+
sdkVersion = "unknown";
110+
if (exceptCounter.shouldPrint()) {
111+
logger.error("Missing sdk.version file!");
112+
}
113+
} else {
114+
Properties properties = new Properties();
115+
properties.load(is);
116+
sdkVersion = properties.getProperty("version");
117+
}
111118
} catch (Throwable ex) {
119+
sdkVersion = "unknown";
112120
if (exceptCounter.shouldPrint()) {
113121
logger.error("DataProxy-SDK get version failure", ex);
114122
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version=${project.version}

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,8 @@
14901490
<exclude>**/dataproxy-sdk-golang/go.sum</exclude>
14911491
<!-- Docker build-->
14921492
<exclude>**/docker/docker-compose/**/**</exclude>
1493+
<!-- dataproxy sdk version -->
1494+
<exclude>**/resources/sdk.version</exclude>
14931495

14941496
</excludes>
14951497
</configuration>

0 commit comments

Comments
 (0)