Skip to content

Commit 35f6d73

Browse files
committed
chore: Address review comments.
1 parent 9ac79fc commit 35f6d73

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

.cloudbuild/library_generation/cloudbuild-library-generation-integration-test.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ steps:
9191
]
9292
env:
9393
- "DOCKER_BUILDKIT=1"
94-
# This does not work until gapic-generator-java is updated to the next released version.
95-
- "TEST_CURRENT_YEAR=2025"
9694
id: generate-libraries
9795
waitFor: [
9896
"build-image",

gapic-generator-java/pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<googleapis.commit>9fcfbea0aa5b50fa22e190faceb073d74504172b</googleapis.commit>
1818
<maven.compiler.source>1.8</maven.compiler.source>
1919
<maven.compiler.target>1.8</maven.compiler.target>
20+
<currentYearOverride>2025</currentYearOverride>
2021
</properties>
2122

2223
<parent>
@@ -323,8 +324,9 @@
323324
target/generated-test-resources/protobuf/descriptor-sets
324325
</additionalClasspathElement>
325326
</additionalClasspathElements>
327+
<!-- Set CURRENT_YEAR_OVERRIDE to a fixed year so the unit test result is consistent -->
326328
<environmentVariables>
327-
<TEST_CURRENT_YEAR>2025</TEST_CURRENT_YEAR>
329+
<CURRENT_YEAR_OVERRIDE>${currentYearOverride}</CURRENT_YEAR_OVERRIDE>
328330
</environmentVariables>
329331
</configuration>
330332
</plugin>

gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/comment/CommentComposer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public class CommentComposer {
8181
"https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library")));
8282

8383
private static String getCurrentYear() {
84-
String testCurrentYear = System.getenv("TEST_CURRENT_YEAR");
84+
String testCurrentYear = System.getenv("CURRENT_YEAR_OVERRIDE");
8585
int currentYearFromCalendar = Calendar.getInstance().get(Calendar.YEAR);
8686
return Strings.isNullOrEmpty(testCurrentYear)
8787
? String.valueOf(currentYearFromCalendar)

hermetic_build/library_generation/owlbot/synthtool/languages/java.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656

5757
def _get_good_license():
58-
current_year = int(os.getenv("TEST_CURRENT_YEAR", date.today().year))
58+
current_year = int(os.getenv("CURRENT_YEAR_OVERRIDE", date.today().year))
5959
good_license = f"""/*
6060
* Copyright {current_year} Google LLC
6161
*

hermetic_build/library_generation/tests/owlbot/java_unit_tests.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
TEST_OWLBOT = Path(__file__).parent.parent / "resources" / "test-owlbot"
2828
FIXTURES = Path(__file__).parent.parent / "resources" / "test-owlbot" / "fixtures"
2929
TEMPLATES_PATH = Path(__file__).parent.parent.parent / "owlbot" / "templates"
30-
TEST_CURRENT_YEAR = "2025"
30+
CURRENT_YEAR_OVERRIDE = "2025"
3131

3232
SAMPLE_METADATA = """
3333
<metadata>
@@ -173,7 +173,7 @@ def test_deprecate_method(self):
173173
)
174174
os.chdir(cwd)
175175

176-
@mock.patch.dict(os.environ, {"TEST_CURRENT_YEAR": TEST_CURRENT_YEAR})
176+
@mock.patch.dict(os.environ, {"CURRENT_YEAR_OVERRIDE": CURRENT_YEAR_OVERRIDE})
177177
def test_fix_proto_license(self):
178178
with tempfile.TemporaryDirectory() as tempdir:
179179
cwd = os.getcwd()
@@ -190,7 +190,7 @@ def test_fix_proto_license(self):
190190
)
191191
os.chdir(cwd)
192192

193-
@mock.patch.dict(os.environ, {"TEST_CURRENT_YEAR": TEST_CURRENT_YEAR})
193+
@mock.patch.dict(os.environ, {"CURRENT_YEAR_OVERRIDE": CURRENT_YEAR_OVERRIDE})
194194
def test_fix_proto_license_idempotent(self):
195195
with tempfile.TemporaryDirectory() as tempdir:
196196
cwd = os.getcwd()
@@ -209,7 +209,7 @@ def test_fix_proto_license_idempotent(self):
209209
)
210210
os.chdir(cwd)
211211

212-
@mock.patch.dict(os.environ, {"TEST_CURRENT_YEAR": TEST_CURRENT_YEAR})
212+
@mock.patch.dict(os.environ, {"CURRENT_YEAR_OVERRIDE": CURRENT_YEAR_OVERRIDE})
213213
def test_fix_grpc_license(self):
214214
with tempfile.TemporaryDirectory() as tempdir:
215215
cwd = os.getcwd()
@@ -226,7 +226,7 @@ def test_fix_grpc_license(self):
226226
)
227227
os.chdir(cwd)
228228

229-
@mock.patch.dict(os.environ, {"TEST_CURRENT_YEAR": TEST_CURRENT_YEAR})
229+
@mock.patch.dict(os.environ, {"CURRENT_YEAR_OVERRIDE": CURRENT_YEAR_OVERRIDE})
230230
def test_fix_grpc_license_idempotent(self):
231231
with tempfile.TemporaryDirectory() as tempdir:
232232
cwd = os.getcwd()

0 commit comments

Comments
 (0)