"""Measure dependency resolution separately; run from the root with network access. A disposable copy replaces the Java executable with /usr/bin/true, keeping the pinned exec-plugin dependencies. No formatter/application code executes. The second invocation uses the populated repository; neither invocation touches the normal Maven cache. Logs and measurements are written under target/. """ from pathlib import Path import json import shutil import subprocess import tempfile import time root = Path(__file__).resolve().parents[2] (root / "target").mkdir(exist_ok=True) with tempfile.TemporaryDirectory(prefix="s8-resolution-") as temporary: fixture = Path(temporary) shutil.copytree(root / ".mvn", fixture / ".mvn") pom = (root / "pom.xml").read_text().replace("${java.home}/bin/java", "/usr/bin/true") (fixture / "pom.xml").write_text(pom) command = ["mvn", "-N", "-B", "-ntp", "-Dmaven.repo.local=" + str(fixture / "repository"), "org.codehaus.mojo:exec-maven-plugin:3.6.3:exec@format"] for label in ("cold-resolution", "warm-resolution"): start = time.monotonic() result = subprocess.run(command, cwd=fixture, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) elapsed = time.monotonic() - start (root / "target" / ("s8-" + label + ".log")).write_text(result.stdout) print(json.dumps(dict(label=label, seconds=round(elapsed, 3), exit=result.returncode)), flush=True) if result.returncode: raise RuntimeError(result.stdout)