Skip to content

feat: migrate grpc-gcp to maven#237

Merged
rahul2393 merged 3 commits into
masterfrom
migrate-grpc-gcp-to-maven
May 11, 2026
Merged

feat: migrate grpc-gcp to maven#237
rahul2393 merged 3 commits into
masterfrom
migrate-grpc-gcp-to-maven

Conversation

@rahul2393
Copy link
Copy Markdown
Collaborator

@rahul2393 rahul2393 commented May 7, 2026

Migrate grpc-gcp build from Gradle to Maven

Replace the Gradle build with a Maven pom.xml that inherits from com.google.cloud:sdk-platform-java config:3.62.0, aligning grpc-gcp with the rest of the google-cloud-java tooling (shared dependency BOM, release profile, formatter, deploy plugin).

This is to migrate the repo to google-cloud-java, later we will switch to use Kokoro and Github actions once migrated for unit/integration tests

b/510577190

@rahul2393 rahul2393 requested a review from nimf May 7, 2026 15:29
@rahul2393 rahul2393 force-pushed the migrate-grpc-gcp-to-maven branch from 8658f91 to 447e1f6 Compare May 8, 2026 14:19

public class GrpcGcpUtil {
public static final String IMPLEMENTATION_VERSION = "1.10.0";
public static final String IMPLEMENTATION_VERSION = "1.11.0-SNAPSHOT";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are we going to keep this in sync with the pom.xml? And do we really need it? Is it used in actual production code, or only in tests? In the latter case, there are probably better solutions than to put it in code. In PGAdapter we have something similar here: https://github.com/GoogleCloudPlatform/pgadapter/blob/d476689dc22670ee227fe65714d1fa849d761ab7/src/main/java/com/google/cloud/spanner/pgadapter/Server.java#L371

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used for the OpenTelemetry instrumentation scope version in production, updating this to what we do in java-spanner where we use GaxProperties.getLibraryVersion(getClass()), which reads Package#getImplementationVersion() from the JAR manifest and falls back to "".

public Object parse(InputStream stream) {
try {
return stream.readAllBytes().toString();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to change this for a migration from Gradle to Maven?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and other changes are here because, google-cloud-java / sdk-platform-java-config enforces Java 8 compatibility, Maven parent compiles with Java 8 release target (--release 8).

  InputStream.readAllBytes() is Java 9+.

So code must avoid it before the module can fit google-cloud-java build.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

.dropWhile(chRef -> prevChannels.contains(chRef))
.findFirst()
.get();
pool.channelRefs.stream().filter(chRef -> !prevChannels.contains(chRef)).findFirst().get();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this does the same as the previous code (?) But could we maybe keep this PR to only the Gradle-to-Maven migration? Same also applies to the other code changes here that are not related to the actual migration. (Meaning: I'm not looking into any of the other code changes in this PR, except where I think it might actually be related to the migration)

Copy link
Copy Markdown
Collaborator Author

@rahul2393 rahul2393 May 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stream#dropWhile is Java 9+, while sdk-platform-java-config enforces Java 8 APIs with --release 8.

Comment thread grpc-gcp/pom.xml Outdated
Comment on lines +60 to +66
<protobuf.version>4.33.2</protobuf.version>
<grpc.version>1.81.0</grpc.version>
<opencensus.version>0.31.1</opencensus.version>
<bigtable.version>2.77.1</bigtable.version>
<spanner.version>6.117.0</spanner.version>
<truth.version>1.4.5</truth.version>
<mockito.version>5.23.0</mockito.version>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that these versions are the same as what they were in the Gradle build file?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we are intentionally updating these to the versions used by the current Cloud Java build (sdk-platform-java-config / google-cloud-shared-dependencies) rather than preserving the old Gradle versions, because the next step is moving this module into google-cloud-java. The other version changes are intentional alignment with the target repo.

Comment thread grpc-gcp/pom.xml
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>sdk-platform-java-config</artifactId>
<version>3.62.0</version><!-- {x-version-update:google-cloud-shared-dependencies:current} -->
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the {x-version-update:google-cloud-shared-dependencies:current} correct here? This is not the reference to the shared-dependencies pom. It is a reference to sdk-platform-java.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will update it google-cloud-jar-parent when we move to monorepo right?

Comment thread grpc-gcp/pom.xml
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-shared-dependencies</artifactId>
<version>${google-cloud-shared-dependencies.version}</version>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this property defined in the parent?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, defined by parent sdk-platform-java-config.

Comment thread grpc-gcp/pom.xml
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be the spanner-bom, and type=pom, scope=import?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And why do we need to import it here anyways? Same also for the bigtable-bom, why is it needed in grpc-gcp?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are here only for test dependencies, Integration tests directly use Spanner + Bigtable client/proto/grpc artifacts. BOMs keep these related test artifacts on one version.

Comment thread grpc-gcp/pom.xml
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK. I assume that this is the reason that we import the pom in the dependency management section.

@rahul2393 rahul2393 requested a review from olavloite May 8, 2026 17:26
public Object parse(InputStream stream) {
try {
return stream.readAllBytes().toString();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

@rahul2393 rahul2393 merged commit 1dcf440 into master May 11, 2026
3 checks passed
@rahul2393 rahul2393 deleted the migrate-grpc-gcp-to-maven branch May 11, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants