You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.6 KiB
44 lines
1.6 KiB
|
2 days ago
|
# -*- coding: utf-8 -*-
|
||
|
|
"""验证 fat jar 内嵌套模块 jar 是否包含本轮 @Schema 改动的编译产物。"""
|
||
|
|
import io, zipfile
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
jar_path = Path(r'crm-app\target\crm-app-1.0.0-SNAPSHOT.jar')
|
||
|
|
outer = zipfile.ZipFile(jar_path)
|
||
|
|
SCHEMA = b'io/swagger/v3/oas/annotations/media/Schema'
|
||
|
|
|
||
|
|
targets = [
|
||
|
|
('crm-base', 'com/crm/base/domain/dto/BaseDTO.class'),
|
||
|
|
('crm-base', 'com/crm/base/domain/entity/BaseEntity.class'),
|
||
|
|
('crm-customer', 'com/crm/customer/domain/entity/CustomerOplog.class'),
|
||
|
|
('crm-customer', 'com/crm/customer/domain/entity/CustomerFollow.class'),
|
||
|
|
('crm-customer', 'com/crm/customer/port/CustomerOpportunityQueryPort$OpportunityItem.class'),
|
||
|
|
('crm-preference', 'com/crm/preference/domain/dto/ColumnPreference.class'),
|
||
|
|
]
|
||
|
|
|
||
|
|
libs = {}
|
||
|
|
for n in outer.namelist():
|
||
|
|
name = n.split('/')[-1]
|
||
|
|
if n.startswith('BOOT-INF/lib/crm-') and name.endswith('.jar') and '-sources' not in name:
|
||
|
|
libs[name] = zipfile.ZipFile(io.BytesIO(outer.read(n)))
|
||
|
|
|
||
|
|
ok = True
|
||
|
|
for module, cls in targets:
|
||
|
|
lib = next((z for name, z in libs.items() if name.startswith(module + '-')), None)
|
||
|
|
if lib is None:
|
||
|
|
print(f'MISSING LIB {module}')
|
||
|
|
ok = False
|
||
|
|
continue
|
||
|
|
try:
|
||
|
|
data = lib.read(cls)
|
||
|
|
except KeyError:
|
||
|
|
print(f'MISSING CLASS {module}:{cls}')
|
||
|
|
ok = False
|
||
|
|
continue
|
||
|
|
has = SCHEMA in data
|
||
|
|
ok = ok and has
|
||
|
|
print(f'{"OK " if has else "BAD"} {module}:{cls.split("/")[-1]} schema_ref={has}')
|
||
|
|
|
||
|
|
print(f'JAR: {jar_path} {jar_path.stat().st_size} bytes')
|
||
|
|
print('ALL_SCHEMA_REFS_PRESENT' if ok else 'VERIFY_FAILED')
|