2727 CODEFLASH_RUNTIME_JAR_NAME ,
2828 CODEFLASH_RUNTIME_VERSION ,
2929 add_codeflash_dependency_to_pom ,
30+ download_from_github_releases ,
3031 find_maven_executable ,
3132 get_jacoco_xml_path ,
3233 install_codeflash_runtime ,
3334 is_jacoco_configured ,
35+ resolve_from_maven_central ,
3436)
3537
3638_MAVEN_NS = "http://maven.apache.org/POM/4.0.0"
@@ -232,16 +234,12 @@ def generate_jacoco_report(exec_file: Path, classfiles_dir: Path, sourcefiles_di
232234 return False
233235
234236
235- # MVN_CENTRAL_TODO: Once codeflash-runtime is published to Maven Central, Maven will
236- # resolve the JAR automatically via the pom.xml <dependency>. At that point step 2
237- # (bundled resources/) can be removed and the JAR excluded from the PyPI wheel.
238237def _find_runtime_jar () -> Path | None :
239- """Find the codeflash-runtime JAR file.
238+ """Find the codeflash-runtime JAR file locally .
240239
241240 Resolution order:
242- 1. Local Maven cache (~/.m2) — fastest, already resolved by Maven or previous install
243- 2. Bundled in Python package (resources/) — available after pip install codeflash
244- 3. Development build directory — only when running from source checkout
241+ 1. Local Maven cache (~/.m2) — fastest, already resolved by Maven Central or previous install
242+ 2. Development build directory — only when running from source checkout
245243 """
246244 # 1. Check local Maven repository (fastest — already installed by Maven or install:install-file)
247245 m2_jar = (
@@ -257,12 +255,7 @@ def _find_runtime_jar() -> Path | None:
257255 if m2_jar .exists ():
258256 return m2_jar
259257
260- # 2. Check bundled JAR in package resources (available when JAR is shipped with pip package)
261- resources_jar = Path (__file__ ).parent / "resources" / CODEFLASH_RUNTIME_JAR_NAME
262- if resources_jar .exists ():
263- return resources_jar
264-
265- # 3. Check development build directory (only when running from source checkout)
258+ # 2. Check development build directory (only when running from source checkout)
266259 dev_jar = (
267260 Path (__file__ ).parent .parent .parent .parent / "codeflash-java-runtime" / "target" / CODEFLASH_RUNTIME_JAR_NAME
268261 )
@@ -291,24 +284,7 @@ def _ensure_codeflash_runtime(maven_root: Path, test_module: str | None) -> bool
291284 if cache_key in _runtime_ensured :
292285 return _runtime_ensured [cache_key ]
293286
294- runtime_jar = _find_runtime_jar ()
295- if runtime_jar is None :
296- logger .error ("codeflash-runtime JAR not found. Generated tests will fail to compile." )
297- return False
298-
299- # Install to local Maven repo if not already there.
300- #
301- # MVN_CENTRAL_TODO: Once codeflash-runtime is published to Maven Central, uncomment
302- # the block below and remove the install:install-file fallback beneath it. Maven will
303- # download the JAR from Central automatically when it sees the <dependency> in pom.xml.
304- #
305- # from codeflash.languages.java.build_tools import resolve_from_maven_central
306- # if resolve_from_maven_central(maven_root):
307- # pass # Maven resolved to ~/.m2 — no manual install needed
308- # else:
309- # if not install_codeflash_runtime(maven_root, runtime_jar):
310- # logger.error("Failed to install codeflash-runtime to local Maven repository")
311- # return False
287+ # Ensure codeflash-runtime is in the local Maven repository.
312288 m2_jar = (
313289 Path .home ()
314290 / ".m2"
@@ -320,10 +296,20 @@ def _ensure_codeflash_runtime(maven_root: Path, test_module: str | None) -> bool
320296 / CODEFLASH_RUNTIME_JAR_NAME
321297 )
322298 if not m2_jar .exists ():
323- logger .info ("Installing codeflash-runtime JAR to local Maven repository" )
324- if not install_codeflash_runtime (maven_root , runtime_jar ):
325- logger .error ("Failed to install codeflash-runtime to local Maven repository" )
326- return False
299+ # Try resolving from Maven Central first
300+ if not resolve_from_maven_central (maven_root ):
301+ # Fallback: download from GitHub Releases (works when Maven Central is unreachable)
302+ runtime_jar = download_from_github_releases ()
303+ if runtime_jar is None :
304+ logger .error (
305+ "codeflash-runtime JAR not found. Maven Central resolution failed and "
306+ "GitHub Releases download failed. Generated tests will fail to compile."
307+ )
308+ return False
309+ logger .info ("Installing codeflash-runtime JAR to local Maven repository from %s" , runtime_jar )
310+ if not install_codeflash_runtime (maven_root , runtime_jar ):
311+ logger .error ("Failed to install codeflash-runtime to local Maven repository" )
312+ return False
327313
328314 # Add dependency to the appropriate pom.xml
329315 if test_module :
0 commit comments