@@ -34,6 +34,7 @@ TARGET_DIR="$WORKING_DIR/$MONOREPO_NAME-target"
3434TRANSFORM_SCRIPT_DIR=" $( cd " $( dirname " $0 " ) " && pwd) "
3535TRANSFORM_SCRIPT=" $TRANSFORM_SCRIPT_DIR /transform_workflow.py"
3636MODERNIZE_POM_SCRIPT=" $TRANSFORM_SCRIPT_DIR /modernize_pom.py"
37+ UPDATE_ROOT_POM_SCRIPT=" $TRANSFORM_SCRIPT_DIR /update_root_pom.py"
3738
3839echo " Starting migration using git read-tree with isolated clones..."
3940
140141
141142# 7.2 Update root pom.xml modules
142143echo " Updating root pom.xml modules..."
143- python3 -c "
144- import sys
145- pom_path = sys.argv[1]
146- module_name = sys.argv[2]
147- new_module = f' <module>{module_name}</module>\n'
148- with open(pom_path, 'r') as f:
149- content = f.read()
150- start_tag = '<modules>'
151- end_tag = '</modules>'
152- start_idx = content.find(start_tag)
153- end_idx = content.find(end_tag)
154- if start_idx != -1 and end_idx != -1:
155- modules_section = content[start_idx + len(start_tag):end_idx]
156- lines = [l for l in modules_section.splitlines(keepends=True) if l.strip()]
157-
158- java_indices = [i for i, l in enumerate(lines) if '<module>java-' in l]
159- if java_indices:
160- start_java = java_indices[0]
161- end_java = java_indices[-1] + 1
162- java_lines = lines[start_java:end_java]
163- if not any(f'<module>{module_name}</module>' in l for l in java_lines):
164- java_lines.append(new_module)
165- java_lines.sort()
166- lines = lines[:start_java] + java_lines + lines[end_java:]
167- else:
168- if not any(f'<module>{module_name}</module>' in l for l in lines):
169- lines.append(new_module)
170-
171- new_content = content[:start_idx + len(start_tag)] + '\n' + ''.join(lines) + ' ' + content[end_idx:]
172- with open(pom_path, 'w') as f:
173- f.write(new_content)
174- " " pom.xml" " $SOURCE_REPO_NAME "
144+ python3 " $UPDATE_ROOT_POM_SCRIPT " " pom.xml" " $SOURCE_REPO_NAME "
175145
176146echo " Committing root pom.xml modules update..."
177147git add pom.xml
0 commit comments