Skip to content

Commit be44402

Browse files
committed
feat(gapic-generator): add NullMarked annotation to generated classes
1 parent 4b0fdc9 commit be44402

10,875 files changed

Lines changed: 30564 additions & 480 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/release-note-generation/split_release_note.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,29 @@ def detect_modules(root_directory: Path):
6363

6464
module_path = repo_metadata_path.parent
6565
module_pom_xml = module_path / 'pom.xml'
66+
owlbot_yaml_path = module_path/ '.OwlBot-hermetic.yaml'
6667
if not module_pom_xml.exists():
6768
continue
6869
tree = ET.parse(module_pom_xml)
6970
root = tree.getroot()
7071
version = root.find('mvn:version', POM_NAMESPACES).text
7172
api_name = None
72-
if repo_metadata_path.exists():
73-
with open(repo_metadata_path, 'r') as file:
74-
repo_metadata = json.load(file)
75-
api_name = repo_metadata.get('api_shortname')
73+
if owlbot_yaml_path.exists():
74+
# If OwlBot configuration file exists (most cases), it's the better
75+
# source to get the OwlBot-generated pull request title prefix than
76+
# the repo-metadata.json
77+
with open(owlbot_yaml_path, 'r') as file:
78+
owlbot_yaml_content = file.read()
79+
match = re.search(r'api-name: (.+)', owlbot_yaml_content)
80+
if match:
81+
api_name = match.group(1)
82+
83+
if not api_name:
84+
# Fallback to repo-metadata.json (e.g. for vertexai or Spanner transitional state)
85+
if repo_metadata_path.exists():
86+
with open(repo_metadata_path, 'r') as file:
87+
repo_metadata = json.load(file)
88+
api_name = repo_metadata.get('api_shortname')
7689

7790
if api_name:
7891
modules.append(LibraryModule(module_path, api_name,
@@ -81,6 +94,7 @@ def detect_modules(root_directory: Path):
8194
else:
8295
raise Exception(f'Could not determine api-name for {repo_metadata_path}')
8396

97+
8498
return modules
8599

86100

.github/workflows/java-cloud-bom-release-note-generation.yaml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,21 @@ name: java-cloud-bom release-notes
1313
env:
1414
BUILD_SUBDIR: java-cloud-bom
1515
jobs:
16+
filter:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
library: ${{ steps.filter.outputs.library }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: dorny/paths-filter@v3
23+
id: filter
24+
with:
25+
filters: |
26+
library:
27+
- 'java-cloud-bom/**'
1628
release-note-generation:
17-
if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, 'libraries-bom/') }}
29+
needs: filter
30+
if: ${{ needs.filter.outputs.library == 'true' }}
1831
runs-on: ubuntu-latest
1932
permissions:
2033
contents: write
@@ -39,10 +52,13 @@ jobs:
3952
if [ -n "${WORKFLOW_DISPATCH_INPUT}" ]; then
4053
echo "WORKFLOW_DISPATCH_INPUT: ${WORKFLOW_DISPATCH_INPUT}"
4154
echo "libraries-bom-version=${WORKFLOW_DISPATCH_INPUT}" >> $GITHUB_OUTPUT
42-
elif [[ "${GITHUB_REF}" == *"refs/tags/libraries-bom/v"* ]]; then
43-
# Example value of GITHUB_REF: refs/tags/libraries-bom/v26.5.0
55+
elif [[ "${GITHUB_REF}" == *"refs/tags/v"* ]]; then
56+
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
57+
# Example value of GITHUB_REF: refs/tags/v26.5.0
58+
# With the single-component setup of Release Please, the Libraries BOM
59+
# version is the version of this repository release.
4460
echo "GITHUB_REF: ${GITHUB_REF}"
45-
VERSION=${GITHUB_REF#*v}
61+
VERSION=${GITHUB_REF#refs/*/v}
4662
echo "libraries-bom-version=${VERSION}" >> $GITHUB_OUTPUT
4763
else
4864
echo "Couldn't find the Libraries BOM version. WORKFLOW_DISPATCH_INPUT \
@@ -73,7 +89,7 @@ jobs:
7389
GH_TOKEN: ${{ github.token }}
7490
- name: Update the release note with release_note.md
7591
run: |
76-
TAG="libraries-bom/v${LIBRARIES_BOM_VERSION}"
92+
TAG="v${LIBRARIES_BOM_VERSION}"
7793
echo "Updating ${TAG}"
7894
gh release edit "${TAG}" --notes-file release_note.md
7995
working-directory: java-cloud-bom/release-note-generation
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
deep-remove-regex:
17+
- "/java-accessapproval/grpc-google-.*/src"
18+
- "/java-accessapproval/proto-google-.*/src"
19+
- "/java-accessapproval/google-.*/src"
20+
- "/java-accessapproval/samples/snippets/generated"
21+
22+
deep-preserve-regex:
23+
- "/.*google-.*/src/main/java/.*/stub/Version.java"
24+
- "/.*google-cloud-accessapproval/src/test/java/com/google/cloud/accessapproval/v1/it"
25+
26+
deep-copy-regex:
27+
- source: "/google/cloud/accessapproval/(v.*)/.*-java/proto-google-.*/src"
28+
dest: "/owl-bot-staging/java-accessapproval/$1/proto-google-cloud-accessapproval-$1/src"
29+
- source: "/google/cloud/accessapproval/(v.*)/.*-java/grpc-google-.*/src"
30+
dest: "/owl-bot-staging/java-accessapproval/$1/grpc-google-cloud-accessapproval-$1/src"
31+
- source: "/google/cloud/accessapproval/(v.*)/.*-java/gapic-google-.*/src"
32+
dest: "/owl-bot-staging/java-accessapproval/$1/google-cloud-accessapproval/src"
33+
- source: "/google/cloud/accessapproval/(v.*)/.*-java/samples/snippets/generated"
34+
dest: "/owl-bot-staging/java-accessapproval/$1/samples/snippets/generated"
35+
36+
api-name: accessapproval

java-accessapproval/.repo-metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"api_description": "enables controlling access to your organization's data by Google personnel.",
66
"client_documentation": "https://cloud.google.com/java/docs/reference/google-cloud-accessapproval/latest/overview",
77
"release_level": "stable",
8-
"transport": "grpc+rest",
8+
"transport": "both",
99
"language": "java",
1010
"repo": "googleapis/google-cloud-java",
1111
"repo_short": "java-accessapproval",

java-accessapproval/google-cloud-accessapproval/src/main/java/com/google/cloud/accessapproval/v1/AccessApprovalAdminClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.List;
3434
import java.util.concurrent.TimeUnit;
3535
import javax.annotation.Generated;
36+
import org.jspecify.annotations.NullMarked;
3637

3738
// AUTO-GENERATED DOCUMENTATION AND CLASS.
3839
/**
@@ -314,6 +315,7 @@
314315
*
315316
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
316317
*/
318+
@NullMarked
317319
@Generated("by gapic-generator-java")
318320
public class AccessApprovalAdminClient implements BackgroundResource {
319321
private final AccessApprovalAdminSettings settings;

java-accessapproval/google-cloud-accessapproval/src/main/java/com/google/cloud/accessapproval/v1/AccessApprovalAdminSettings.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.io.IOException;
3636
import java.util.List;
3737
import javax.annotation.Generated;
38+
import org.jspecify.annotations.NullMarked;
3839

3940
// AUTO-GENERATED DOCUMENTATION AND CLASS.
4041
/**
@@ -88,6 +89,7 @@
8889
* Guide](https://docs.cloud.google.com/java/docs/client-retries) for additional support in setting
8990
* retries.
9091
*/
92+
@NullMarked
9193
@Generated("by gapic-generator-java")
9294
public class AccessApprovalAdminSettings extends ClientSettings<AccessApprovalAdminSettings> {
9395

java-accessapproval/google-cloud-accessapproval/src/main/java/com/google/cloud/accessapproval/v1/stub/AccessApprovalStub.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
import com.google.cloud.accessapproval.v1.UpdateAccessApprovalSettingsMessage;
3636
import com.google.protobuf.Empty;
3737
import javax.annotation.Generated;
38+
import org.jspecify.annotations.NullMarked;
3839

3940
// AUTO-GENERATED DOCUMENTATION AND CLASS.
4041
/**
4142
* Base stub class for the AccessApproval service API.
4243
*
4344
* <p>This class is for advanced usage and reflects the underlying API directly.
4445
*/
46+
@NullMarked
4547
@Generated("by gapic-generator-java")
4648
public abstract class AccessApprovalStub implements BackgroundResource {
4749

java-accessapproval/google-cloud-accessapproval/src/main/java/com/google/cloud/accessapproval/v1/stub/AccessApprovalStubSettings.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import java.time.Duration;
6868
import java.util.List;
6969
import javax.annotation.Generated;
70+
import org.jspecify.annotations.NullMarked;
7071

7172
// AUTO-GENERATED DOCUMENTATION AND CLASS.
7273
/**
@@ -120,6 +121,7 @@
120121
* Guide](https://docs.cloud.google.com/java/docs/client-retries) for additional support in setting
121122
* retries.
122123
*/
124+
@NullMarked
123125
@Generated("by gapic-generator-java")
124126
@SuppressWarnings("CanonicalDuration")
125127
public class AccessApprovalStubSettings extends StubSettings<AccessApprovalStubSettings> {

java-accessapproval/google-cloud-accessapproval/src/main/java/com/google/cloud/accessapproval/v1/stub/GrpcAccessApprovalCallableFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@
3434
import com.google.longrunning.Operation;
3535
import com.google.longrunning.stub.OperationsStub;
3636
import javax.annotation.Generated;
37+
import org.jspecify.annotations.NullMarked;
3738

3839
// AUTO-GENERATED DOCUMENTATION AND CLASS.
3940
/**
4041
* gRPC callable factory implementation for the AccessApproval service API.
4142
*
4243
* <p>This class is for advanced usage.
4344
*/
45+
@NullMarked
4446
@Generated("by gapic-generator-java")
4547
public class GrpcAccessApprovalCallableFactory implements GrpcStubCallableFactory {
4648

java-accessapproval/google-cloud-accessapproval/src/main/java/com/google/cloud/accessapproval/v1/stub/GrpcAccessApprovalStub.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@
4545
import java.io.IOException;
4646
import java.util.concurrent.TimeUnit;
4747
import javax.annotation.Generated;
48+
import org.jspecify.annotations.NullMarked;
4849

4950
// AUTO-GENERATED DOCUMENTATION AND CLASS.
5051
/**
5152
* gRPC stub implementation for the AccessApproval service API.
5253
*
5354
* <p>This class is for advanced usage and reflects the underlying API directly.
5455
*/
56+
@NullMarked
5557
@Generated("by gapic-generator-java")
5658
public class GrpcAccessApprovalStub extends AccessApprovalStub {
5759
private static final MethodDescriptor<ListApprovalRequestsMessage, ListApprovalRequestsResponse>

0 commit comments

Comments
 (0)