|
18 | 18 | PROJ_DIR = SCRIPT_DIR.parent |
19 | 19 |
|
20 | 20 | COMPOSE_FILE = "./scripts/build/docker-compose.build.yml" |
| 21 | +ENV_FILE = SCRIPT_DIR / "build" / ".env" |
21 | 22 |
|
22 | 23 | JDK_VERSIONS = ["8", "11", "17", "21"] |
23 | 24 | BUILD_TOOLS = ["maven", "gradle"] |
@@ -65,10 +66,41 @@ def run_build(compose, service, *, background=False, evomaster=False): |
65 | 66 | return subprocess.run(cmd, check=False) |
66 | 67 |
|
67 | 68 |
|
68 | | -def copy_additional_files(compose, *, evomaster=False): |
69 | | - print(">>> Copying additional files to dist...") |
70 | | - env_args = ["-e", "BUILD_EVOMASTER=true"] if evomaster else [] |
71 | | - run(compose + ["-f", COMPOSE_FILE, "run", "--rm", "-T"] + env_args + ["copy-additional-files"]) |
| 69 | +def load_env(key): |
| 70 | + for line in ENV_FILE.read_text().splitlines(): |
| 71 | + line = line.strip() |
| 72 | + if line.startswith(f"{key}="): |
| 73 | + return line.split("=", 1)[1] |
| 74 | + return None |
| 75 | + |
| 76 | + |
| 77 | +def copy_additional_files(*, evomaster=False): |
| 78 | + dist = PROJ_DIR / "dist" |
| 79 | + dist.mkdir(parents=True, exist_ok=True) |
| 80 | + |
| 81 | + jacoco_dir = PROJ_DIR / "jacoco" |
| 82 | + for name in ["jacocoagent.jar", "jacococli.jar"]: |
| 83 | + src = jacoco_dir / name |
| 84 | + if src.exists(): |
| 85 | + shutil.copy2(src, dist / name) |
| 86 | + print(f" Copied {name}") |
| 87 | + else: |
| 88 | + print(f" WARNING: {src} not found, skipping") |
| 89 | + |
| 90 | + if evomaster: |
| 91 | + version = load_env("EVOMASTER_VERSION") |
| 92 | + if not version: |
| 93 | + print(" ERROR: EVOMASTER_VERSION not found in .env") |
| 94 | + sys.exit(1) |
| 95 | + agent_name = f"evomaster-client-java-instrumentation-{version}.jar" |
| 96 | + src = Path.home() / ".m2" / "repository" / "org" / "evomaster" / "evomaster-client-java-instrumentation" / version / agent_name |
| 97 | + if src.exists(): |
| 98 | + shutil.copy2(src, dist / "evomaster-agent.jar") |
| 99 | + print(f" Copied evomaster-agent.jar (v{version})") |
| 100 | + else: |
| 101 | + print(f" ERROR: {src} not found") |
| 102 | + sys.exit(1) |
| 103 | + |
72 | 104 | print("Additional files copied!\n") |
73 | 105 |
|
74 | 106 |
|
@@ -186,7 +218,7 @@ def main(): |
186 | 218 | print("Copy Additional Files Only Mode") |
187 | 219 | dist_dir.mkdir(parents=True, exist_ok=True) |
188 | 220 | os.chdir(PROJ_DIR) |
189 | | - copy_additional_files(compose, evomaster=args.evomaster) |
| 221 | + copy_additional_files(evomaster=args.evomaster) |
190 | 222 | print("Files copied successfully!") |
191 | 223 | for f in ["evomaster-agent.jar", "jacocoagent.jar", "jacococli.jar"]: |
192 | 224 | show_jar(f) |
@@ -328,7 +360,7 @@ def main(): |
328 | 360 | sys.exit(1) |
329 | 361 | print(f" Completed in {svc_elapsed}\n") |
330 | 362 |
|
331 | | - copy_additional_files(compose, evomaster=args.evomaster) |
| 363 | + copy_additional_files(evomaster=args.evomaster) |
332 | 364 |
|
333 | 365 | # Cleanup |
334 | 366 | print("Cleaning up Docker containers...") |
|
0 commit comments