@@ -536,35 +536,46 @@ def modify_script(self, script_path):
536
536
def add_maven_repos (self , content , local_path ):
537
537
new_maven_repo = f"""
538
538
maven {{
539
- url ' { local_path } '
539
+ url " { local_path } "
540
540
metadataSources {{
541
541
mavenPom()
542
542
artifact()
543
543
}}
544
544
}}
545
545
"""
546
546
547
- # Find the repositories block manually and modify it
548
- start_idx = content .find ('repositories {' )
549
- if start_idx == - 1 :
550
- # If no repositories block is found, return the content as is
551
- return content
547
+ modified_content = ''
548
+ start_idx = 0
549
+ while True :
550
+ # Find the repositories block manually and modify it
551
+ start_idx_of_repo = content .find ('repositories {' , start_idx )
552
+ if start_idx_of_repo == - 1 :
553
+ # No more repositories blocks found
554
+ break
552
555
553
- # Find the matching closing brace for the repositories block
554
- open_braces = 1
555
- end_idx = start_idx + len ('repositories {' )
556
- while open_braces > 0 and end_idx < len (content ):
557
- if content [end_idx ] == '{' :
558
- open_braces += 1
559
- elif content [end_idx ] == '}' :
560
- open_braces -= 1
561
- end_idx += 1
556
+ # Find the matching closing brace for the repositories block
557
+ open_braces = 1
558
+ end_idx = start_idx_of_repo + len ('repositories {' )
559
+ while open_braces > 0 and end_idx < len (content ):
560
+ if content [end_idx ] == '{' :
561
+ open_braces += 1
562
+ elif content [end_idx ] == '}' :
563
+ open_braces -= 1
564
+ end_idx += 1
562
565
563
- # Insert the new maven repository before the closing brace
564
- modified_repositories_block = content [start_idx :end_idx - 1 ].strip () + f"\n { new_maven_repo .strip ()} \n " + content [end_idx - 1 :end_idx ]
566
+ # Insert the new maven repository before the closing brace
567
+ modified_repositories_block = content [start_idx_of_repo :end_idx - 1 ].strip () + f"\n { new_maven_repo .strip ()} \n " + content [end_idx - 1 :end_idx ]
565
568
566
- # Replace the old block with the modified one
567
- return content [:start_idx ] + modified_repositories_block + content [end_idx :]
569
+ # Append the modified block to the modified_content string
570
+ modified_content += content [start_idx :start_idx_of_repo ] + modified_repositories_block
571
+
572
+ # Move the start_idx to the end of the current block
573
+ start_idx = end_idx
574
+
575
+ # Append any remaining content after the last repositoroies block
576
+ modified_content += content [start_idx :]
577
+
578
+ return modified_content
568
579
569
580
def create_init_script (directory , init_name , content ):
570
581
qct_gradle_dir = os .path .join (directory , 'qct-gradle' )
@@ -636,7 +647,7 @@ def run(directory_path):
636
647
create_run_task (directory_path , 'custom-init.gradle' , custom_init_script_content , 'cacheToMavenLocal' )
637
648
create_run_task (directory_path ,'buildEnv-copy-init.gradle' , run_build_env_copy_content , 'runAndParseBuildEnvironment' )
638
649
build_offline_dependencies = create_init_script (directory_path , 'use-downloaded-dependencies.gradle' , use_offline_dependency )
639
- #run_offline_build(build_offline_dependencies, directory_path)
650
+ # run_offline_build(build_offline_dependencies, directory_path)
640
651
except Exception as e :
641
652
print (f"An error occurred: { e } " )
642
653
sys .exit (1 )
@@ -657,6 +668,7 @@ def run_properties(dir,action_1, distBase, distPath, zip_name):
657
668
manager .set_custom_distribution (distributionBase , distributionPath )
658
669
659
670
#do a gradlew to pull the artifacts to the specified destination
671
+ # TODO: do a gradlew subprocess here before modifying the content of the distribution to pull the zip
660
672
run_gradlew (project_directory )
661
673
662
674
#modify the initialization scripts under init.d
0 commit comments