Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: populate
.repo-metadata.json
from highest version (#2890)
In this PR: - populate `.repo-metadata.json` from highest stable version of proto paths. The `.repo-metadata.json` is only generated once per library and the first item in proto paths is used, so the proto paths with the highest stable version should be the first item after sorting the proto paths in the library. The method used to compare two proto paths, `a` and `b`: 1. if both of `a` and `b` don't have a version, the one with lower depth is smaller. 2. if either `a` or `b` has a version, the one with the version is smaller. 3. if either `a` or `b` has a stable version, but not both, the one with the stable version is smaller, e.g., `google/spanner/v2` is smaller than `google/spanner/v3beta`. 4. if both `a` and `b` have a non-stable version, the one with higher version is smaller, e.g., `google/spanner/v2beta1` is smaller than `google/spanner/v2alpha2`. 5. if both `a` and `b` have a stable version, the one with lower depth is smaller, e.g., `google/spanner/v1` is smaller than `google/spanner/admin/v1`, `google/spanner/v1` is smaller than `google/spanner/admin/v2` 6. if both `a` and `b` have a stable version and the depth is the same, the one with higher version is smaller, e.g., `google/spanner/v2` is smaller than `google/spanner/v1`. Test the change: 1. build the image locally: ``` docker build -f .cloudbuild/library_generation/library_generation.Dockerfile -t local:latest . ``` 2. build the generator locally: ``` mvn -V -B -ntp clean install -DskipTests ``` 3. run the image: ``` docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workspace" -v "$HOME/.m2:/home/.m2" local:latest ``` Result: 1. no change in common protos 2. `transport` changed to `both` in `java-iam/.repo-metadata.json`. This is expected since the `transport` in [`google/iam/v2/BUILD.bazel`](https://github.com/googleapis/googleapis/blob/master/google/iam/v2/BUILD.bazel#L94) is `grpc+rest`. Without this change, the `transport` is parsed from `google/iam/v2/BUILD.bazel`, which doesn't have a `java_gapic_library` target, thus the value is `grpc` by default.
- Loading branch information