mirror of
https://github.com/hwanny1128/HGZero.git
synced 2026-06-12 22:59:10 +00:00
stt service 빌드 에러 해결
This commit is contained in:
@@ -37,43 +37,26 @@ def get_project_root():
|
||||
def parse_run_configurations(project_root, service_name=None):
|
||||
"""Parse run configuration files from .run directories"""
|
||||
configurations = {}
|
||||
|
||||
|
||||
if service_name:
|
||||
# Parse specific service configuration
|
||||
# Try multiple file name patterns
|
||||
run_dir = project_root / service_name / '.run'
|
||||
if run_dir.exists():
|
||||
# Pattern 1: {service_name}.run.xml
|
||||
run_config_path = run_dir / f'{service_name}.run.xml'
|
||||
if not run_config_path.exists():
|
||||
# Pattern 2: {service_name}-service.run.xml
|
||||
run_config_path = run_dir / f'{service_name}-service.run.xml'
|
||||
if not run_config_path.exists():
|
||||
# Pattern 3: Find any .run.xml file
|
||||
xml_files = list(run_dir.glob('*.run.xml'))
|
||||
if xml_files:
|
||||
run_config_path = xml_files[0]
|
||||
|
||||
if run_config_path.exists():
|
||||
config = parse_single_run_config(run_config_path, service_name)
|
||||
if config:
|
||||
configurations[service_name] = config
|
||||
else:
|
||||
print(f"[ERROR] Cannot find run configuration in: {run_dir}")
|
||||
run_config_path = project_root / service_name / '.run' / f'{service_name}.run.xml'
|
||||
if run_config_path.exists():
|
||||
config = parse_single_run_config(run_config_path, service_name)
|
||||
if config:
|
||||
configurations[service_name] = config
|
||||
else:
|
||||
print(f"[ERROR] Cannot find .run directory: {run_dir}")
|
||||
print(f"[ERROR] Cannot find run configuration: {run_config_path}")
|
||||
else:
|
||||
# Find all service directories
|
||||
service_dirs = ['user-service', 'location-service', 'trip-service', 'ai-service', 'meeting']
|
||||
service_dirs = ['user-service', 'location-service', 'trip-service', 'ai-service']
|
||||
for service in service_dirs:
|
||||
run_dir = project_root / service / '.run'
|
||||
if run_dir.exists():
|
||||
xml_files = list(run_dir.glob('*.run.xml'))
|
||||
if xml_files:
|
||||
config = parse_single_run_config(xml_files[0], service)
|
||||
if config:
|
||||
configurations[service] = config
|
||||
|
||||
run_config_path = project_root / service / '.run' / f'{service}.run.xml'
|
||||
if run_config_path.exists():
|
||||
config = parse_single_run_config(run_config_path, service)
|
||||
if config:
|
||||
configurations[service] = config
|
||||
|
||||
return configurations
|
||||
|
||||
|
||||
@@ -82,43 +65,25 @@ def parse_single_run_config(config_path, service_name):
|
||||
try:
|
||||
tree = ET.parse(config_path)
|
||||
root = tree.getroot()
|
||||
|
||||
|
||||
# Find configuration element
|
||||
config = root.find('.//configuration[@type="GradleRunConfiguration"]')
|
||||
if config is None:
|
||||
print(f"[WARNING] No Gradle configuration found in {config_path}")
|
||||
return None
|
||||
|
||||
# Extract externalProjectPath
|
||||
external_project_path = None
|
||||
external_settings = config.find('.//ExternalSystemSettings')
|
||||
if external_settings is not None:
|
||||
external_path_option = external_settings.find('.//option[@name="externalProjectPath"]')
|
||||
if external_path_option is not None:
|
||||
external_project_path = external_path_option.get('value')
|
||||
|
||||
# Extract environment variables from new format
|
||||
|
||||
# Extract environment variables
|
||||
env_vars = {}
|
||||
envs_element = config.find('.//envs')
|
||||
if envs_element is not None:
|
||||
for env in envs_element.findall('env'):
|
||||
key = env.get('name')
|
||||
value = env.get('value')
|
||||
if key and value:
|
||||
env_vars[key] = value
|
||||
|
||||
# Also try old format
|
||||
if not env_vars:
|
||||
env_option = config.find('.//option[@name="env"]')
|
||||
if env_option is not None:
|
||||
env_map = env_option.find('map')
|
||||
if env_map is not None:
|
||||
for entry in env_map.findall('entry'):
|
||||
key = entry.get('key')
|
||||
value = entry.get('value')
|
||||
if key and value:
|
||||
env_vars[key] = value
|
||||
|
||||
env_option = config.find('.//option[@name="env"]')
|
||||
if env_option is not None:
|
||||
env_map = env_option.find('map')
|
||||
if env_map is not None:
|
||||
for entry in env_map.findall('entry'):
|
||||
key = entry.get('key')
|
||||
value = entry.get('value')
|
||||
if key and value:
|
||||
env_vars[key] = value
|
||||
|
||||
# Extract task names
|
||||
task_names = []
|
||||
task_names_option = config.find('.//option[@name="taskNames"]')
|
||||
@@ -129,17 +94,16 @@ def parse_single_run_config(config_path, service_name):
|
||||
value = option.get('value')
|
||||
if value:
|
||||
task_names.append(value)
|
||||
|
||||
|
||||
if env_vars or task_names:
|
||||
return {
|
||||
'env_vars': env_vars,
|
||||
'task_names': task_names,
|
||||
'config_path': str(config_path),
|
||||
'external_project_path': external_project_path
|
||||
'config_path': str(config_path)
|
||||
}
|
||||
|
||||
|
||||
return None
|
||||
|
||||
|
||||
except ET.ParseError as e:
|
||||
print(f"[ERROR] XML parsing error in {config_path}: {e}")
|
||||
return None
|
||||
@@ -165,51 +129,24 @@ def get_gradle_command(project_root):
|
||||
def run_service(service_name, config, project_root):
|
||||
"""Run service"""
|
||||
print(f"[START] Starting {service_name} service...")
|
||||
|
||||
|
||||
# Set environment variables
|
||||
env = os.environ.copy()
|
||||
for key, value in config['env_vars'].items():
|
||||
env[key] = value
|
||||
print(f" [ENV] {key}={value}")
|
||||
|
||||
# Determine if this is a subproject
|
||||
subproject_name = None
|
||||
working_dir = project_root
|
||||
|
||||
if config.get('external_project_path'):
|
||||
# Replace $PROJECT_DIR$ with actual project root
|
||||
external_path = config['external_project_path'].replace('$PROJECT_DIR$', str(project_root))
|
||||
external_path_obj = Path(external_path)
|
||||
|
||||
# Check if external path is a subdirectory of project root
|
||||
try:
|
||||
relative = external_path_obj.relative_to(project_root)
|
||||
# If it's a subdirectory, it's likely a subproject
|
||||
if str(relative) != '.':
|
||||
subproject_name = str(relative).split('/')[0]
|
||||
print(f"[INFO] Detected subproject: {subproject_name}")
|
||||
except ValueError:
|
||||
# Not a subdirectory, use as working directory
|
||||
working_dir = external_path_obj
|
||||
print(f"[INFO] Using external project path: {working_dir}")
|
||||
|
||||
|
||||
# Prepare Gradle command
|
||||
gradle_cmd = get_gradle_command(project_root)
|
||||
|
||||
|
||||
# Execute tasks
|
||||
for task_name in config['task_names']:
|
||||
# If subproject detected, prefix task name
|
||||
if subproject_name:
|
||||
prefixed_task = f":{subproject_name}:{task_name}"
|
||||
print(f"\n[RUN] Executing: {prefixed_task} (subproject: {subproject_name})")
|
||||
else:
|
||||
prefixed_task = task_name
|
||||
print(f"\n[RUN] Executing: {task_name}")
|
||||
|
||||
cmd = [gradle_cmd, prefixed_task]
|
||||
|
||||
print(f"\n[RUN] Executing: {task_name}")
|
||||
|
||||
cmd = [gradle_cmd, task_name]
|
||||
|
||||
try:
|
||||
# Execute from project root
|
||||
# Execute from project root directory
|
||||
process = subprocess.Popen(
|
||||
cmd,
|
||||
cwd=project_root,
|
||||
@@ -221,24 +158,24 @@ def run_service(service_name, config, project_root):
|
||||
encoding='utf-8',
|
||||
errors='replace'
|
||||
)
|
||||
|
||||
|
||||
print(f"[CMD] Command: {' '.join(cmd)}")
|
||||
print(f"[DIR] Working directory: {project_root}")
|
||||
print("=" * 50)
|
||||
|
||||
|
||||
# Real-time output
|
||||
for line in process.stdout:
|
||||
print(line.rstrip())
|
||||
|
||||
|
||||
# Wait for process completion
|
||||
process.wait()
|
||||
|
||||
|
||||
if process.returncode == 0:
|
||||
print(f"\n[SUCCESS] {task_name} execution completed")
|
||||
else:
|
||||
print(f"\n[FAILED] {task_name} execution failed (exit code: {process.returncode})")
|
||||
return False
|
||||
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print(f"\n[STOP] Interrupted by user")
|
||||
process.terminate()
|
||||
@@ -246,7 +183,7 @@ def run_service(service_name, config, project_root):
|
||||
except Exception as e:
|
||||
print(f"\n[ERROR] Execution error: {e}")
|
||||
return False
|
||||
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user