File tree Expand file tree Collapse file tree 1 file changed +35
-3
lines changed
google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/internal/wire Expand file tree Collapse file tree 1 file changed +35
-3
lines changed Original file line number Diff line number Diff line change 1616
1717package com .google .cloud .pubsublite .internal .wire ;
1818
19- /** The version number of this library. Should be updated whenever the version is updated. */
19+ import com .google .api .gax .core .GaxProperties ;
20+
21+ /** The version number of this library.*/
2022final class Versions {
2123 private Versions () {}
2224
23- static final int MAJOR_VERSION = 0 ;
24- static final int MINOR_VERSION = 0 ;
25+ private static String [] GetVersionSplits () {
26+ try {
27+ String versionString = GaxProperties .getLibraryVersion (Versions .class );
28+ return versionString .split ("." );
29+ } catch (Exception e ) {
30+ return new String [0 ];
31+ }
32+ }
33+
34+ private static int GetMajorVersion () {
35+ String [] splits = GetVersionSplits ();
36+ if (splits .length != 3 ) return 0 ;
37+ try {
38+ return Integer .parseInt (splits [0 ]);
39+ } catch (NumberFormatException e ) {
40+ return 0 ;
41+ }
42+ }
43+
44+ private static int GetMinorVersion () {
45+ String [] splits = GetVersionSplits ();
46+ if (splits .length != 3 ) return 0 ;
47+ try {
48+ return Integer .parseInt (splits [1 ]);
49+ } catch (NumberFormatException e ) {
50+ return 0 ;
51+ }
52+ }
53+
54+ // TODO: Do this using generation automation as opposed to maven packaging.
55+ static final int MAJOR_VERSION = GetMajorVersion ();
56+ static final int MINOR_VERSION = GetMinorVersion ();
2557}
You can’t perform that action at this time.
0 commit comments