Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(spring): use parsed api shortname as libname #1084

Merged
merged 3 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/main/java/com/google/api/generator/spring/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.google.api.generator.gapic.model.Service;
import com.google.common.base.CaseFormat;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.protobuf.Duration;
import com.google.protobuf.util.Durations;
import io.grpc.serviceconfig.MethodConfig.RetryPolicy;
Expand Down Expand Up @@ -60,12 +59,12 @@ public static String getLibName(GapicContext context) {
// discrepancies
// eg. for vision proto: "com.google.cloud.vision.v1"
// https://github.com/googleapis/java-vision/blob/main/proto-google-cloud-vision-v1/src/main/proto/google/cloud/vision/v1/image_annotator.proto#L36
List<String> pakkagePhrases = Splitter.on(".").splitToList(getPackageName(context));
return pakkagePhrases.get(pakkagePhrases.size() - 2);
// List<String> pakkagePhrases = Splitter.on(".").splitToList(getPackageName(context));
// return pakkagePhrases.get(pakkagePhrases.size() - 2);

// Option 3: Parse ApiShortName from service proto's default host (e.g. vision.googleapis.com)
// TODO: Replace implementation above to reuse parsing logic from SampleGen:
// https://github.com/googleapis/gapic-generator-java/pull/1040
// Option 3: Use parsed apiShortName from service proto's default host
// (e.g. vision.googleapis.com => vision)
return context.services().get(0).apiShortName();
}

public static String getPackageName(GapicContext context) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** Spring Boot auto-configurations for showcase. */
/** Spring Boot auto-configurations for localhost:7469. */
@Generated("by gapic-generator-java")
package com.google.showcase.v1beta1.spring;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

/** Spring Boot auto-configurations for showcase. */
/** Spring Boot auto-configurations for localhost:7469. */
@Generated("by gapic-generator-java")
package com.google.showcase.v1beta1.spring;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "com.google.showcase.v1beta1.spring.auto.echo.enabled",
"type": "java.lang.Boolean",
"description": "Auto-configure Google Cloud showcase/Echo components.",
"description": "Auto-configure Google Cloud localhost:7469/Echo components.",
"defaultValue": true
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<groupId>com.google.cloud</groupId>
<artifactId>com-google-showcase-v1beta1-spring-starter</artifactId>
<version>{{starter-version}}</version>
<name>Spring Boot Starter - showcase</name>
<description>Spring Boot Starter with AutoConfiguration for showcase</description>
<name>Spring Boot Starter - localhost:7469</name>
<description>Spring Boot Starter with AutoConfiguration for localhost:7469</description>


<dependencies>
Expand Down