[java-storage-nio]: transitive google-cloud-storage dependency causes scope conflicts when used at test scope

オープン
#12,897 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Dhriti07 がすでに取り組んでいます。

2026年8月25日 から。

評価

この issue はまだ評価されていません。

説明

api: storage

Problem

google-cloud-nio is commonly used at test scope to provide a java.nio.file.FileSystemProvider for gs:// URIs in tests. However, it depends on google-cloud-storage at compile scope, which pulls in ~15 transitive dependencies.

When a project already has google-cloud-storage at compile scope (e.g. via spring-cloud-gcp-starter-storage), adding google-cloud-nio at test scope can cause Maven's "nearest definition wins" rule to silently re-resolve google-cloud-storage and its transitives at test scope. Build tools that strip test-scoped jars from the runtime image (e.g. Jib) then produce containers with missing classes, causing ClassNotFoundException at startup.

The current workaround is to manually exclude google-cloud-storage from google-cloud-nio:

<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-nio</artifactId>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-storage</artifactId>
        </exclusion>
    </exclusions>
</dependency>

This is fragile and non-obvious. Every consumer hitting this has to independently discover the problem and apply the same fix.

Suggestion

One of:

  1. Separate artifact: publish a google-cloud-nio-testing artifact that contains only the FileSystemProvider registration and declares google-cloud-storage as provided or optional. This matches the pattern used by other GCP libraries (e.g. google-cloud-bigtable-emulator-core).

  2. Mark google-cloud-storage as optional: in the existing google-cloud-nio POM, declare google-cloud-storage as <optional>true</optional>. Consumers already have it on the classpath at compile scope via their GCS integration. This avoids the transitive scope conflict without a new artifact.

主要言語
Java
スター
2.1k
フォーク
1.2k
平均マージ
2日 14時間
マージ済み PR(30日)
192

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

googleapis/google-cloud-java のほかの issue

googleapis/google-cloud-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。