Skip to content

Commit 40c8314

Browse files
committed
fix: also preserve explicit google-cloud-x dependency versions
1 parent 44bb26a commit 40c8314

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

monorepo-migration/modernize_pom.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def modernize_pom(file_path, parent_version, source_repo_name=None):
101101
current_dependency_lines = [line]
102102
should_preserve = False
103103
current_group_id = None
104+
current_artifact_id = None
104105
has_version = False
105106
continue
106107
if '</dependency>' in line:
@@ -110,8 +111,11 @@ def modernize_pom(file_path, parent_version, source_repo_name=None):
110111
# Preservation logic:
111112
# 1. Has x-version-update comment
112113
# 2. Is NOT com.google group AND has a version tag
114+
# 3. Is com.google.cloud group AND artifactId starts with google-cloud- AND has a version tag
113115
is_external = current_group_id and not current_group_id.startswith('com.google')
114-
if should_preserve or (is_external and has_version):
116+
is_google_cloud_lib = current_group_id == 'com.google.cloud' and current_artifact_id and current_artifact_id.startswith('google-cloud-')
117+
118+
if should_preserve or (is_external and has_version) or (is_google_cloud_lib and has_version):
115119
new_lines.extend(current_dependency_lines)
116120
continue
117121

@@ -123,6 +127,10 @@ def modernize_pom(file_path, parent_version, source_repo_name=None):
123127
match = re.search(r'<groupId>(.*?)</groupId>', line)
124128
if match:
125129
current_group_id = match.group(1).strip()
130+
if '<artifactId>' in line:
131+
match = re.search(r'<artifactId>(.*?)</artifactId>', line)
132+
if match:
133+
current_artifact_id = match.group(1).strip()
126134
if '<version>' in line:
127135
has_version = True
128136
continue

0 commit comments

Comments
 (0)