Closed phillipshaong closed 1 week ago
Checking.
Thank you for preparing the project (https://github.com/phillipshaong/java-gcp-secrets-manager-test/tree/main). I opened the project in IntelliJ (Community Edition) and it asked to add lines to module-info.java for the missing packages:
After adding these lines, the module-info.java looks:
module com.gcp_secrets_manager_test.app {
requires google.cloud.secretmanager;
requires proto.google.cloud.secretmanager.v1;
requires protobuf.java;
}
Even after the compilation errors disappear, the Java module system does not work; I got java: the unnamed module reads package com.google.cloud.secretmanager.v1 from both google.cloud.secretmanager and proto.google.cloud.secretmanager.v1
.
I'm afraid that the Cloud SDK for Java does not work with the Java platform module system that use module-info.java.
Thanks for checking @suztomo. Does that mean, at this moment, the Cloud Java SDK for Secret Manager doesn't work in a modularized project? Is there any workaround for that? My project needs to include the module-info.java
file for other dependencies.
I'm afraid that's the case. I created https://github.com/googleapis/google-cloud-java/issues/10979 for the issue.
The current known workaround is to repackage the JAR files. As we gather information, we'll enrich the issue. Of course, if you put the Cloud Java SDK for Secret Manager in the class path (not module paths), it just works fine. Module path and class path can coexist.
Good to know, thank you for taking a look into it and the recommendation.
Issue
I would like to use GCP Secrets Manager for my Java application. The main trouble comes when using the module-info.java file, if I use a version of Java less than 9 that doesn't have the module-info.java file, then it works fine. The main error that comes up is
The import com.google.cloud.secretmanager.v1.{Class Name} cannot be resolved Java (268435846).
, and that applies to the following classes:The only class that correctly imports is
SecretManagerServiceClient
.Environment details
Steps to reproduce
LINK TO REPRODUCIBLE CODE: https://github.com/phillipshaong/java-gcp-secrets-manager-test/tree/main
Code example
Stack trace
N/A
External references such as API reference guides
-https://cloud.google.com/secret-manager/docs/reference/libraries#client-libraries-install-java
Any additional information below
N/A
Following these steps guarantees the quickest resolution possible.
Thanks!