| 12345678910111213141516171819202122232425262728293031323334 |
- # -*- coding: utf-8 -*-
- """Spring Boot 4 / Jackson 3 迁移:包名批量替换。
- Jackson 3 把 com.fasterxml.jackson.databind|core 迁到 tools.jackson.*,
- 但注解(com.fasterxml.jackson.annotation)为向后兼容保持在原包,不能动。
- 用法:python tools/migrate_jackson3.py [--dry]
- """
- import sys
- from _root import ROOT
- SRC = ROOT / "yoshop-java/src/main/java"
- RULES = [
- ("com.fasterxml.jackson.databind", "tools.jackson.databind"),
- ("com.fasterxml.jackson.core", "tools.jackson.core"),
- ]
- dry = "--dry" in sys.argv
- changed = []
- for f in SRC.rglob("*.java"):
- text = f.read_text(encoding="utf-8")
- new = text
- for old, rep in RULES:
- new = new.replace(old, rep)
- if new != text:
- changed.append(f)
- if not dry:
- f.write_text(new, encoding="utf-8")
- print("%s %d files" % ("would change" if dry else "changed", len(changed)))
- for f in changed[:10]:
- print(" ", f.relative_to(ROOT))
|