googleapis / googleapis/google-cloud-java

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

未关闭
#12,897 0 条评论 0 个 reaction 已指派 1 人 已被 @Dhriti07 认领 在 GitHub 查看
api: storage
主要语言
Java
星标
2.1k
派生
1.2k
平均合并
1 天 23 小时
30 天内合并 PR
154

描述

## 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`:

```xml

com.google.cloud
google-cloud-nio
test


com.google.cloud
google-cloud-storage

```

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 `true`. Consumers already have it on the classpath at compile scope via their GCS integration. This avoids the transitive scope conflict without a new artifact.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。