Skip to content

Commit 38bace4

Browse files
authored
Update spi classes (#1817)
1 parent ed012ef commit 38bace4

File tree

23 files changed

+317
-32
lines changed

23 files changed

+317
-32
lines changed

google-cloud-errorreporting/pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
</parent>
1616
<properties>
1717
<site.installationModule>google-cloud-errorreporting</site.installationModule>
18+
<artifact.version>${project.version}</artifact.version>
1819
</properties>
1920
<dependencies>
2021
<dependency>
@@ -87,6 +88,22 @@
8788
</profiles>
8889
<build>
8990
<plugins>
91+
<plugin>
92+
<groupId>org.codehaus.mojo</groupId>
93+
<artifactId>properties-maven-plugin</artifactId>
94+
<version>1.0-alpha-2</version>
95+
<executions>
96+
<execution>
97+
<phase>generate-resources</phase>
98+
<goals>
99+
<goal>write-project-properties</goal>
100+
</goals>
101+
<configuration>
102+
<outputFile>${project.build.outputDirectory}/project.properties</outputFile>
103+
</configuration>
104+
</execution>
105+
</executions>
106+
</plugin>
90107
<plugin>
91108
<groupId>org.codehaus.mojo</groupId>
92109
<artifactId>build-helper-maven-plugin</artifactId>

google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorGroupServiceSettings.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.google.cloud.errorreporting.spi.v1beta1;
1717

1818
import com.google.api.gax.core.GoogleCredentialsProvider;
19+
import com.google.api.gax.core.PropertiesProvider;
1920
import com.google.api.gax.core.RetrySettings;
2021
import com.google.api.gax.grpc.ChannelProvider;
2122
import com.google.api.gax.grpc.ClientSettings;
@@ -82,6 +83,11 @@ public class ErrorGroupServiceSettings extends ClientSettings {
8283
private static final String DEFAULT_GAPIC_NAME = "gapic";
8384
private static final String DEFAULT_GAPIC_VERSION = "";
8485

86+
private static final String PROPERTIES_FILE = "/project.properties";
87+
private static final String META_VERSION_KEY = "artifact.version";
88+
89+
private static String gapicVersion;
90+
8591
private final SimpleCallSettings<GetGroupRequest, ErrorGroup> getGroupSettings;
8692
private final SimpleCallSettings<UpdateGroupRequest, ErrorGroup> updateGroupSettings;
8793

@@ -130,8 +136,13 @@ public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder
130136
}
131137

132138
private static String getGapicVersion() {
133-
String packageVersion = ErrorGroupServiceSettings.class.getPackage().getImplementationVersion();
134-
return packageVersion != null ? packageVersion : DEFAULT_GAPIC_VERSION;
139+
if (gapicVersion == null) {
140+
gapicVersion =
141+
PropertiesProvider.loadProperty(
142+
ErrorGroupServiceSettings.class, PROPERTIES_FILE, META_VERSION_KEY);
143+
gapicVersion = gapicVersion == null ? DEFAULT_GAPIC_VERSION : gapicVersion;
144+
}
145+
return gapicVersion;
135146
}
136147

137148
/** Returns a builder for this class with recommended defaults. */

google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceSettings.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static com.google.cloud.errorreporting.spi.v1beta1.PagedResponseWrappers.ListGroupStatsPagedResponse;
2020

2121
import com.google.api.gax.core.GoogleCredentialsProvider;
22+
import com.google.api.gax.core.PropertiesProvider;
2223
import com.google.api.gax.core.RetrySettings;
2324
import com.google.api.gax.grpc.CallContext;
2425
import com.google.api.gax.grpc.ChannelProvider;
@@ -95,6 +96,11 @@ public class ErrorStatsServiceSettings extends ClientSettings {
9596
private static final String DEFAULT_GAPIC_NAME = "gapic";
9697
private static final String DEFAULT_GAPIC_VERSION = "";
9798

99+
private static final String PROPERTIES_FILE = "/project.properties";
100+
private static final String META_VERSION_KEY = "artifact.version";
101+
102+
private static String gapicVersion;
103+
98104
private final PagedCallSettings<
99105
ListGroupStatsRequest, ListGroupStatsResponse, ListGroupStatsPagedResponse>
100106
listGroupStatsSettings;
@@ -155,8 +161,13 @@ public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder
155161
}
156162

157163
private static String getGapicVersion() {
158-
String packageVersion = ErrorStatsServiceSettings.class.getPackage().getImplementationVersion();
159-
return packageVersion != null ? packageVersion : DEFAULT_GAPIC_VERSION;
164+
if (gapicVersion == null) {
165+
gapicVersion =
166+
PropertiesProvider.loadProperty(
167+
ErrorStatsServiceSettings.class, PROPERTIES_FILE, META_VERSION_KEY);
168+
gapicVersion = gapicVersion == null ? DEFAULT_GAPIC_VERSION : gapicVersion;
169+
}
170+
return gapicVersion;
160171
}
161172

162173
/** Returns a builder for this class with recommended defaults. */

google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ReportErrorsServiceSettings.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.google.cloud.errorreporting.spi.v1beta1;
1717

1818
import com.google.api.gax.core.GoogleCredentialsProvider;
19+
import com.google.api.gax.core.PropertiesProvider;
1920
import com.google.api.gax.core.RetrySettings;
2021
import com.google.api.gax.grpc.ChannelProvider;
2122
import com.google.api.gax.grpc.ClientSettings;
@@ -81,6 +82,11 @@ public class ReportErrorsServiceSettings extends ClientSettings {
8182
private static final String DEFAULT_GAPIC_NAME = "gapic";
8283
private static final String DEFAULT_GAPIC_VERSION = "";
8384

85+
private static final String PROPERTIES_FILE = "/project.properties";
86+
private static final String META_VERSION_KEY = "artifact.version";
87+
88+
private static String gapicVersion;
89+
8490
private final SimpleCallSettings<ReportErrorEventRequest, ReportErrorEventResponse>
8591
reportErrorEventSettings;
8692

@@ -125,9 +131,13 @@ public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder
125131
}
126132

127133
private static String getGapicVersion() {
128-
String packageVersion =
129-
ReportErrorsServiceSettings.class.getPackage().getImplementationVersion();
130-
return packageVersion != null ? packageVersion : DEFAULT_GAPIC_VERSION;
134+
if (gapicVersion == null) {
135+
gapicVersion =
136+
PropertiesProvider.loadProperty(
137+
ReportErrorsServiceSettings.class, PROPERTIES_FILE, META_VERSION_KEY);
138+
gapicVersion = gapicVersion == null ? DEFAULT_GAPIC_VERSION : gapicVersion;
139+
}
140+
return gapicVersion;
131141
}
132142

133143
/** Returns a builder for this class with recommended defaults. */

google-cloud-language/pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
</parent>
1616
<properties>
1717
<site.installationModule>google-cloud-language</site.installationModule>
18+
<artifact.version>${project.version}</artifact.version>
1819
</properties>
1920
<dependencies>
2021
<dependency>
@@ -87,6 +88,22 @@
8788
</profiles>
8889
<build>
8990
<plugins>
91+
<plugin>
92+
<groupId>org.codehaus.mojo</groupId>
93+
<artifactId>properties-maven-plugin</artifactId>
94+
<version>1.0-alpha-2</version>
95+
<executions>
96+
<execution>
97+
<phase>generate-resources</phase>
98+
<goals>
99+
<goal>write-project-properties</goal>
100+
</goals>
101+
<configuration>
102+
<outputFile>${project.build.outputDirectory}/project.properties</outputFile>
103+
</configuration>
104+
</execution>
105+
</executions>
106+
</plugin>
90107
<plugin>
91108
<groupId>org.codehaus.mojo</groupId>
92109
<artifactId>build-helper-maven-plugin</artifactId>

google-cloud-language/src/main/java/com/google/cloud/language/spi/v1/LanguageServiceSettings.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.google.cloud.language.spi.v1;
1717

1818
import com.google.api.gax.core.GoogleCredentialsProvider;
19+
import com.google.api.gax.core.PropertiesProvider;
1920
import com.google.api.gax.core.RetrySettings;
2021
import com.google.api.gax.grpc.ChannelProvider;
2122
import com.google.api.gax.grpc.ClientSettings;
@@ -86,6 +87,11 @@ public class LanguageServiceSettings extends ClientSettings {
8687
private static final String DEFAULT_GAPIC_NAME = "gapic";
8788
private static final String DEFAULT_GAPIC_VERSION = "";
8889

90+
private static final String PROPERTIES_FILE = "/project.properties";
91+
private static final String META_VERSION_KEY = "artifact.version";
92+
93+
private static String gapicVersion;
94+
8995
private final SimpleCallSettings<AnalyzeSentimentRequest, AnalyzeSentimentResponse>
9096
analyzeSentimentSettings;
9197
private final SimpleCallSettings<AnalyzeEntitiesRequest, AnalyzeEntitiesResponse>
@@ -151,8 +157,13 @@ public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder
151157
}
152158

153159
private static String getGapicVersion() {
154-
String packageVersion = LanguageServiceSettings.class.getPackage().getImplementationVersion();
155-
return packageVersion != null ? packageVersion : DEFAULT_GAPIC_VERSION;
160+
if (gapicVersion == null) {
161+
gapicVersion =
162+
PropertiesProvider.loadProperty(
163+
LanguageServiceSettings.class, PROPERTIES_FILE, META_VERSION_KEY);
164+
gapicVersion = gapicVersion == null ? DEFAULT_GAPIC_VERSION : gapicVersion;
165+
}
166+
return gapicVersion;
156167
}
157168

158169
/** Returns a builder for this class with recommended defaults. */

google-cloud-logging/pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
</parent>
1717
<properties>
1818
<site.installationModule>google-cloud-logging</site.installationModule>
19+
<artifact.version>${project.version}</artifact.version>
1920
</properties>
2021
<dependencies>
2122
<dependency>
@@ -88,6 +89,22 @@
8889
</profiles>
8990
<build>
9091
<plugins>
92+
<plugin>
93+
<groupId>org.codehaus.mojo</groupId>
94+
<artifactId>properties-maven-plugin</artifactId>
95+
<version>1.0-alpha-2</version>
96+
<executions>
97+
<execution>
98+
<phase>generate-resources</phase>
99+
<goals>
100+
<goal>write-project-properties</goal>
101+
</goals>
102+
<configuration>
103+
<outputFile>${project.build.outputDirectory}/project.properties</outputFile>
104+
</configuration>
105+
</execution>
106+
</executions>
107+
</plugin>
91108
<plugin>
92109
<groupId>org.codehaus.mojo</groupId>
93110
<artifactId>build-helper-maven-plugin</artifactId>

google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/ConfigSettings.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListSinksPagedResponse;
1919

2020
import com.google.api.gax.core.GoogleCredentialsProvider;
21+
import com.google.api.gax.core.PropertiesProvider;
2122
import com.google.api.gax.core.RetrySettings;
2223
import com.google.api.gax.grpc.CallContext;
2324
import com.google.api.gax.grpc.ChannelProvider;
@@ -99,6 +100,11 @@ public class ConfigSettings extends ClientSettings {
99100
private static final String DEFAULT_GAPIC_NAME = "gapic";
100101
private static final String DEFAULT_GAPIC_VERSION = "";
101102

103+
private static final String PROPERTIES_FILE = "/project.properties";
104+
private static final String META_VERSION_KEY = "artifact.version";
105+
106+
private static String gapicVersion;
107+
102108
private final PagedCallSettings<ListSinksRequest, ListSinksResponse, ListSinksPagedResponse>
103109
listSinksSettings;
104110
private final SimpleCallSettings<GetSinkRequest, LogSink> getSinkSettings;
@@ -167,8 +173,12 @@ public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder
167173
}
168174

169175
private static String getGapicVersion() {
170-
String packageVersion = ConfigSettings.class.getPackage().getImplementationVersion();
171-
return packageVersion != null ? packageVersion : DEFAULT_GAPIC_VERSION;
176+
if (gapicVersion == null) {
177+
gapicVersion =
178+
PropertiesProvider.loadProperty(ConfigSettings.class, PROPERTIES_FILE, META_VERSION_KEY);
179+
gapicVersion = gapicVersion == null ? DEFAULT_GAPIC_VERSION : gapicVersion;
180+
}
181+
return gapicVersion;
172182
}
173183

174184
/** Returns a builder for this class with recommended defaults. */

google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingSettings.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.google.api.gax.core.FlowControlSettings;
2626
import com.google.api.gax.core.FlowController.LimitExceededBehavior;
2727
import com.google.api.gax.core.GoogleCredentialsProvider;
28+
import com.google.api.gax.core.PropertiesProvider;
2829
import com.google.api.gax.core.RetrySettings;
2930
import com.google.api.gax.grpc.BatchedRequestIssuer;
3031
import com.google.api.gax.grpc.BatchingCallSettings;
@@ -113,6 +114,11 @@ public class LoggingSettings extends ClientSettings {
113114
private static final String DEFAULT_GAPIC_NAME = "gapic";
114115
private static final String DEFAULT_GAPIC_VERSION = "";
115116

117+
private static final String PROPERTIES_FILE = "/project.properties";
118+
private static final String META_VERSION_KEY = "artifact.version";
119+
120+
private static String gapicVersion;
121+
116122
private final SimpleCallSettings<DeleteLogRequest, Empty> deleteLogSettings;
117123
private final BatchingCallSettings<WriteLogEntriesRequest, WriteLogEntriesResponse>
118124
writeLogEntriesSettings;
@@ -193,8 +199,12 @@ public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder
193199
}
194200

195201
private static String getGapicVersion() {
196-
String packageVersion = LoggingSettings.class.getPackage().getImplementationVersion();
197-
return packageVersion != null ? packageVersion : DEFAULT_GAPIC_VERSION;
202+
if (gapicVersion == null) {
203+
gapicVersion =
204+
PropertiesProvider.loadProperty(LoggingSettings.class, PROPERTIES_FILE, META_VERSION_KEY);
205+
gapicVersion = gapicVersion == null ? DEFAULT_GAPIC_VERSION : gapicVersion;
206+
}
207+
return gapicVersion;
198208
}
199209

200210
/** Returns a builder for this class with recommended defaults. */

google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsSettings.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogMetricsPagedResponse;
1919

2020
import com.google.api.gax.core.GoogleCredentialsProvider;
21+
import com.google.api.gax.core.PropertiesProvider;
2122
import com.google.api.gax.core.RetrySettings;
2223
import com.google.api.gax.grpc.CallContext;
2324
import com.google.api.gax.grpc.ChannelProvider;
@@ -99,6 +100,11 @@ public class MetricsSettings extends ClientSettings {
99100
private static final String DEFAULT_GAPIC_NAME = "gapic";
100101
private static final String DEFAULT_GAPIC_VERSION = "";
101102

103+
private static final String PROPERTIES_FILE = "/project.properties";
104+
private static final String META_VERSION_KEY = "artifact.version";
105+
106+
private static String gapicVersion;
107+
102108
private final PagedCallSettings<
103109
ListLogMetricsRequest, ListLogMetricsResponse, ListLogMetricsPagedResponse>
104110
listLogMetricsSettings;
@@ -169,8 +175,12 @@ public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder
169175
}
170176

171177
private static String getGapicVersion() {
172-
String packageVersion = MetricsSettings.class.getPackage().getImplementationVersion();
173-
return packageVersion != null ? packageVersion : DEFAULT_GAPIC_VERSION;
178+
if (gapicVersion == null) {
179+
gapicVersion =
180+
PropertiesProvider.loadProperty(MetricsSettings.class, PROPERTIES_FILE, META_VERSION_KEY);
181+
gapicVersion = gapicVersion == null ? DEFAULT_GAPIC_VERSION : gapicVersion;
182+
}
183+
return gapicVersion;
174184
}
175185

176186
/** Returns a builder for this class with recommended defaults. */

0 commit comments

Comments
 (0)