Skip to content

Commit b44cc0a

Browse files
committed
copy update
1 parent 682e139 commit b44cc0a

File tree

2 files changed

+38
-25
lines changed

2 files changed

+38
-25
lines changed

scripts/build/docker-compose.build.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -264,25 +264,6 @@ services:
264264
fi
265265
echo 'JDK 21 Maven build completed'
266266
267-
copy-additional-files:
268-
image: alpine:latest
269-
volumes:
270-
- ${HOME}/.m2:/root/.m2
271-
- ${DIST_FOLDER}:/dist
272-
- ${JACOCO_FOLDER}:/jacoco
273-
command:
274-
- sh
275-
- -c
276-
- |
277-
set -e
278-
cp /jacoco/jacocoagent.jar /dist/
279-
cp /jacoco/jacococli.jar /dist/
280-
echo 'Jacoco files copied'
281-
if [ "$${BUILD_EVOMASTER:-false}" = "true" ]; then
282-
cp /root/.m2/repository/org/evomaster/evomaster-client-java-instrumentation/${EVOMASTER_VERSION}/evomaster-client-java-instrumentation-${EVOMASTER_VERSION}.jar /dist/evomaster-agent.jar
283-
echo 'evomaster-agent.jar copied'
284-
fi
285-
286267
volumes:
287268
gradle-cache-jdk8:
288269
gradle-cache-jdk11:

scripts/dist-docker.py

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
PROJ_DIR = SCRIPT_DIR.parent
1919

2020
COMPOSE_FILE = "./scripts/build/docker-compose.build.yml"
21+
ENV_FILE = SCRIPT_DIR / "build" / ".env"
2122

2223
JDK_VERSIONS = ["8", "11", "17", "21"]
2324
BUILD_TOOLS = ["maven", "gradle"]
@@ -65,10 +66,41 @@ def run_build(compose, service, *, background=False, evomaster=False):
6566
return subprocess.run(cmd, check=False)
6667

6768

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+
72104
print("Additional files copied!\n")
73105

74106

@@ -186,7 +218,7 @@ def main():
186218
print("Copy Additional Files Only Mode")
187219
dist_dir.mkdir(parents=True, exist_ok=True)
188220
os.chdir(PROJ_DIR)
189-
copy_additional_files(compose, evomaster=args.evomaster)
221+
copy_additional_files(evomaster=args.evomaster)
190222
print("Files copied successfully!")
191223
for f in ["evomaster-agent.jar", "jacocoagent.jar", "jacococli.jar"]:
192224
show_jar(f)
@@ -328,7 +360,7 @@ def main():
328360
sys.exit(1)
329361
print(f" Completed in {svc_elapsed}\n")
330362

331-
copy_additional_files(compose, evomaster=args.evomaster)
363+
copy_additional_files(evomaster=args.evomaster)
332364

333365
# Cleanup
334366
print("Cleaning up Docker containers...")

0 commit comments

Comments
 (0)