Skip to content

Commit 12b7ab5

Browse files
committed
Revert "Version info from property file (#802)"
This reverts commit 3ef2887.
1 parent 920a156 commit 12b7ab5

File tree

4 files changed

+19
-50
lines changed

4 files changed

+19
-50
lines changed

build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020
allprojects {
2121
group = "co.elastic.clients"
22-
version = (File(project.rootDir, "config/version.txt").readText().trim() + "-SNAPSHOT")
22+
// Release manager provides a $VERSION. If not present, it's a local or CI snapshot build.
23+
version = System.getenv("VERSION") ?:
24+
(File(project.rootDir, "config/version.txt").readText().trim() + "-SNAPSHOT")
2325

2426
repositories {
2527
maven {

java-client-serverless/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ checkstyle {
3737
toolVersion = "10.16.0"
3838
}
3939

40-
version = (File(project.rootDir, "config/version-serverless.txt").readText().trim() + "-SNAPSHOT")
40+
// GitHub Maven repo doesn't like 1.0.0+20231031-SNAPSHOT
41+
version = "1.0.0-20231031-SNAPSHOT"
4142

4243
signing {
4344
sign(publishing.publications)

java-client-serverless/src/main/resources/co/elastic/clients/version.properties

Lines changed: 0 additions & 21 deletions
This file was deleted.

java-client/src/main/java/co/elastic/clients/transport/Version.java

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,8 @@
1919

2020
package co.elastic.clients.transport;
2121

22-
import co.elastic.clients.ApiClient;
23-
2422
import javax.annotation.Nullable;
25-
import java.io.InputStream;
2623
import java.util.Objects;
27-
import java.util.Properties;
2824

2925
/**
3026
* This class represents a SemVer version, with an optional patch revision.
@@ -49,20 +45,20 @@ public static Version parse(String version) {
4945
int hyphen = version.indexOf('-');
5046
if (hyphen >= 0) {
5147
// Has prerelease. May be followed buy build information
52-
prerelease = version.substring(hyphen + 1);
48+
prerelease = version.substring(hyphen+1);
5349
version = version.substring(0, hyphen);
5450

5551
int plus = prerelease.indexOf('+');
5652
if (plus >= 0) {
57-
build = prerelease.substring(0, plus + 1);
53+
build = prerelease.substring(0, plus+1);
5854
prerelease = prerelease.substring(0, plus);
5955
}
6056
}
6157

6258
int plus = version.indexOf('+');
6359
if (plus >= 0) {
6460
// Has build information
65-
build = version.substring(0, plus + 1);
61+
build = version.substring(0, plus+1);
6662
version = version.substring(0, plus);
6763
}
6864

@@ -72,7 +68,8 @@ public static Version parse(String version) {
7268
int minor = (bits.length >= 2) ? Integer.parseInt(bits[1]) : 0;
7369
int maintenance = (bits.length >= 3) ? Integer.parseInt(bits[2]) : -1;
7470
return new Version(major, minor, maintenance, prerelease, build);
75-
} catch (NumberFormatException ex) {
71+
}
72+
catch(NumberFormatException ex) {
7673
return null;
7774
}
7875
}
@@ -81,8 +78,7 @@ public Version(int major, int minor, int maintenance, boolean isPreRelease) {
8178
this(major, minor, maintenance, isPreRelease ? "p" : null, null);
8279
}
8380

84-
public Version(int major, int minor, int maintenance, @Nullable String prerelease,
85-
@Nullable String build) {
81+
public Version(int major, int minor, int maintenance, @Nullable String prerelease, @Nullable String build) {
8682
this.major = major;
8783
this.minor = minor;
8884
this.maintenance = maintenance;
@@ -112,10 +108,10 @@ public boolean equals(Object other) {
112108
if (!(other instanceof Version)) return false;
113109
Version that = (Version) other;
114110
return (major == that.major &&
115-
minor == that.minor &&
116-
maintenance == that.maintenance &&
117-
Objects.equals(prerelease, that.prerelease) &&
118-
Objects.equals(build, that.build));
111+
minor == that.minor &&
112+
maintenance == that.maintenance &&
113+
Objects.equals(prerelease, that.prerelease) &&
114+
Objects.equals(build, that.build));
119115
}
120116

121117
@Override
@@ -150,19 +146,10 @@ public String toString() {
150146

151147
static {
152148
Version version = null;
153-
InputStream in = ApiClient.class.getResourceAsStream("version.properties");
154-
if (in != null) {
155-
Properties properties = new Properties();
156-
try {
157-
properties.load(in);
158-
String versionStr = properties.getProperty("version");
159-
if (versionStr != null) {
160-
version = Version.parse(versionStr);
161-
}
162-
} catch (Exception e) {
163-
// Failed to parse version from file, trying from VersionInfo
164-
version = Version.parse(VersionInfo.VERSION);
165-
}
149+
try {
150+
version = Version.parse(VersionInfo.VERSION);
151+
} catch (Exception e) {
152+
// Failed to parse version
166153
}
167154
VERSION = version;
168155
}

0 commit comments

Comments
 (0)