[gax-java] fix: make GaxProperties.version accessible in Android #1117
Changes from 1 commit
c12779a
1305707
15565c6
ca91181
7fd9779
374f4f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,12 +57,16 @@ public static String getLibraryVersion(Class<?> libraryClass) { | |
* method are expected to be cached. | ||
*/ | ||
public static String getLibraryVersion(Class<?> libraryClass, String propertyName) { | ||
String version = getLibraryVersion(libraryClass); | ||
if (!DEFAULT_VERSION.equals(version)) { | ||
return version; | ||
String version = null; | ||
// Always read GaxProperties' version from the properties file. | ||
if (!libraryClass.equals(GaxProperties.class)) { | ||
version = getLibraryVersion(libraryClass); | ||
if (!DEFAULT_VERSION.equals(version)) { | ||
return version; | ||
} | ||
} | ||
|
||
try (InputStream in = libraryClass.getResourceAsStream("/dependencies.properties")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed? Most probably this will break execution as a bazel artifact (i.e. when a client library is build with bazel and executed from bazel context). In any case, introducing another properties file will duplicate version information in two places. Plus, the version in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is similar to this PR in google-http-java-client. Note that On the other hand, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tl;dr; Please strongly consider just making
Note, As for In any case, most importantly, this value is not updated automatically so after the next release it will start reporting wrong version number. There is TODO, but it is not sufficient (after all this PR fixes one relatively small issue, so introducing a future issue with it is not "cost efficient"). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO we shouldn't include all of We also did not have a |
||
try (InputStream in = libraryClass.getResourceAsStream("/gradle.properties")) { | ||
if (in != null) { | ||
Properties props = new Properties(); | ||
props.load(in); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# TODO: Populate this from dependencies.properties version property (for proper Gradle-Bazel sync) | ||
version.gax = "1.56.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the if? seems we can return unconditionally here if it is the default version. Or do you want to read from gradle.properties instead if this is the default version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this seems applicable to any generic library class (i.e. keep reading if the version is empty, aka
DEFAULT_VERSION
), I was trying to keep the non-GaxProperties logic the same.