|
62 | 62 |
|
63 | 63 | CODEFLASH_CACHE_DIR = Path.home() / ".cache" / "codeflash" |
64 | 64 |
|
65 | | -CODEFLASH_DEPENDENCY_SNIPPET = """\ |
| 65 | +CODEFLASH_DEPENDENCY_SNIPPET = f"""\ |
66 | 66 | <dependency> |
67 | 67 | <groupId>com.codeflash</groupId> |
68 | 68 | <artifactId>codeflash-runtime</artifactId> |
69 | | - <version>1.0.0</version> |
| 69 | + <version>{CODEFLASH_RUNTIME_VERSION}</version> |
70 | 70 | <scope>test</scope> |
71 | 71 | </dependency> |
72 | 72 | </dependencies>""" |
@@ -140,7 +140,7 @@ def install_codeflash_runtime(project_root: Path, runtime_jar_path: Path, mvn: s |
140 | 140 | f"-Dfile={runtime_jar_path}", |
141 | 141 | "-DgroupId=com.codeflash", |
142 | 142 | "-DartifactId=codeflash-runtime", |
143 | | - "-Dversion=1.0.0", |
| 143 | + f"-Dversion={CODEFLASH_RUNTIME_VERSION}", |
144 | 144 | "-Dpackaging=jar", |
145 | 145 | "-B", |
146 | 146 | ] |
@@ -288,26 +288,26 @@ def add_codeflash_dependency(pom_path: Path) -> bool: |
288 | 288 | content = pom_path.read_text(encoding="utf-8") |
289 | 289 |
|
290 | 290 | if "codeflash-runtime" in content: |
291 | | - if "<scope>system</scope>" in content: |
292 | | - |
293 | | - def replace_system_dep(match: re.Match[str]) -> str: |
294 | | - block: str = match.group(0) |
295 | | - if "codeflash-runtime" in block and "<scope>system</scope>" in block: |
296 | | - return ( |
297 | | - "<dependency>\n" |
298 | | - " <groupId>com.codeflash</groupId>\n" |
299 | | - " <artifactId>codeflash-runtime</artifactId>\n" |
300 | | - " <version>1.0.0</version>\n" |
301 | | - " <scope>test</scope>\n" |
302 | | - " </dependency>" |
303 | | - ) |
| 291 | + |
| 292 | + def update_codeflash_dep(match: re.Match[str]) -> str: |
| 293 | + block: str = match.group(0) |
| 294 | + if "codeflash-runtime" not in block: |
304 | 295 | return block |
| 296 | + return ( |
| 297 | + "<dependency>\n" |
| 298 | + " <groupId>com.codeflash</groupId>\n" |
| 299 | + " <artifactId>codeflash-runtime</artifactId>\n" |
| 300 | + f" <version>{CODEFLASH_RUNTIME_VERSION}</version>\n" |
| 301 | + " <scope>test</scope>\n" |
| 302 | + " </dependency>" |
| 303 | + ) |
305 | 304 |
|
306 | | - content = re.sub(r"<dependency>[\s\S]*?</dependency>", replace_system_dep, content) |
307 | | - pom_path.write_text(content, encoding="utf-8") |
308 | | - logger.info("Replaced system-scope codeflash-runtime dependency with test scope") |
309 | | - return True |
310 | | - logger.info("codeflash-runtime dependency already present in pom.xml") |
| 305 | + updated = re.sub(r"<dependency>[\s\S]*?</dependency>", update_codeflash_dep, content) |
| 306 | + if updated != content: |
| 307 | + pom_path.write_text(updated, encoding="utf-8") |
| 308 | + logger.info("Updated codeflash-runtime dependency to version %s in pom.xml", CODEFLASH_RUNTIME_VERSION) |
| 309 | + else: |
| 310 | + logger.info("codeflash-runtime dependency already up to date in pom.xml") |
311 | 311 | return True |
312 | 312 |
|
313 | 313 | closing_tag = "</dependencies>" |
@@ -571,8 +571,8 @@ class MavenStrategy(BuildToolStrategy): |
571 | 571 | / "com" |
572 | 572 | / "codeflash" |
573 | 573 | / "codeflash-runtime" |
574 | | - / "1.0.0" |
575 | | - / "codeflash-runtime-1.0.0.jar" |
| 574 | + / "1.0.1" |
| 575 | + / "codeflash-runtime-1.0.1.jar" |
576 | 576 | ) |
577 | 577 |
|
578 | 578 | @property |
|
0 commit comments