Files
DongHyeonka 414666cfc7 build: 템플릿 밖에서 혼자 빌드·배포되는 Gradle 루트를 만든다
옮겨 온 gRPC 모듈은 템플릿의 두 번째 빌드(optional build)였다. 그 빌드는
템플릿 build-logic·카탈로그·registry·config를 상대 경로로 읽었고,
grpc-operation-ledger-jpa는 템플릿 persistence-jpa의 testFixtures 파일
셋을 빌드 때 복사해 왔다. 별도 repo에는 그 경로가 없다.

repo 루트를 Gradle 루트로 둔다.
- build-logic: 템플릿 22df3525의 src/build-logic을 복사하고 쓰지 않는
  플러그인(bootrun-dotenv, redis topology, config contract,
  spring-library, optional registry, purity 태스크)을 뺐다. 출처와 고친
  곳은 build-logic/UPSTREAM.md에 적었다(설계 10.3절 L1).
- registry config/architecture/modules.json: 템플릿의 optional-grpc 9행,
  source_path는 Gradle 루트 기준.
- 카탈로그·config: 이 repo가 쓰는 항목만. SpotBugs 제외는 이 repo
  클래스와 일반 규칙만 남겼다.
- group은 gradle.properties의 libraryGroup(com.hyeonworks.grpc)에서
  읽는다. 버전은 -PreleaseVersion 말고 RELEASE_TAG(vX.Y.Z)에서도 읽고,
  다른 모양의 태그는 빌드 전에 거부한다.
- 배포: 새 ca.library-publishing이 모듈마다 Maven publication(sources·
  javadoc jar, versionMapping으로 해석된 버전)과 저장소 gitea·staging,
  SIGNING_KEY가 있으면 PGP 서명을 단다. 루트는 SBOM artifact
  grpc-library와 단계 태스크 ci·mainCheck·releaseCheck·release·
  releaseRehearsal을 가진다. Trivy·Buf는 scripts/tool.sh가 SHA-256으로
  고정해 받는다.
- testFixtures 결합(설계 4.6절 2번)은 integrationTest 안 사본으로 끊었다.
- Buf lint·breaking은 Gradle 태스크(scripts/buf.sh)로 ci에 넣었다.

버린 대안: build-logic을 템플릿이 배포(L2, 순환), 공통 repo(L3, repo가
하나 더), 표준 플러그인만으로 새로 쓰기(L4, strict lane과 방향 검사를
잃음). SBOM은 CycloneDX Gradle 플러그인 대신 이미 고정해 쓰는 Trivy로
만든다(도구를 늘리지 않는다).

위험: strictlane 단계 검사는 included build 태스크를 따라가다 실패해서
그 태스크를 건너뛰게 고쳤다(UPSTREAM.md). Gitea에 실제로 올리는 경로는
비밀 값이 없어 이 커밋에서는 시험하지 못했다.

검증(desktop, 이 트리): ./gradlew ci rc=0, 테스트 739개(build-logic
포함) 중 첫 실행 실패 1개(템플릿 경로를 찾던 GrpcPackageOwnershipTest)를
고친 뒤 통과. ./gradlew verifyStrictLaneStages --dry-run rc=0.

Refs: design-docs repo-structure/05-library-repos.md 4.6·7·10절
2026-11-08 11:10:21 +09:00

86 lines
3.6 KiB
Python

#!/usr/bin/env python3
"""Checks a staged release (build/staging-repository) file by file before anything is uploaded.
check-staging.py <repository dir> <group> <version> signed|unsigned <artifact>...
For every module: the jar, sources and javadoc jars, POM and Gradle module file, each with its
.md5/.sha1/.sha256/.sha512 checksum (and .asc when signed), and every dependency in the POM and the
module file carries a version. The last check is the publishing trap the design names: the modules
declare most dependencies without a version and let a BOM fill it, and a published file written
from the declarations would leave consumers nothing to resolve. For the SBOM artifact
(grpc-library): its POM and the CycloneDX JSON.
"""
import json
import sys
import xml.etree.ElementTree as ET
from pathlib import Path
CHECKSUMS = (".md5", ".sha1", ".sha256", ".sha512")
POM = "{http://maven.apache.org/POM/4.0.0}"
def expect(path: Path, signed: bool, problems: list[str]) -> None:
if not path.is_file():
problems.append(f"missing {path.name}")
return
for suffix in CHECKSUMS + ((".asc",) if signed else ()):
if not path.with_name(path.name + suffix).is_file():
problems.append(f"missing {path.name}{suffix}")
def unversioned_pom(pom: Path) -> list[str]:
root = ET.parse(pom).getroot()
out = []
for dependency in root.iter(f"{POM}dependency"):
version = dependency.findtext(f"{POM}version")
if not version or not version.strip():
out.append(f"{dependency.findtext(f'{POM}groupId')}:{dependency.findtext(f'{POM}artifactId')}")
return out
def unversioned_module(module: Path) -> list[str]:
data = json.loads(module.read_text(encoding="utf-8"))
out = []
for variant in data.get("variants", []):
for dependency in variant.get("dependencies", []):
version = dependency.get("version") or {}
if not any(version.get(k) for k in ("requires", "strictly", "prefers")):
out.append(f"{variant['name']}: {dependency['group']}:{dependency['module']}")
return out
def main() -> int:
if len(sys.argv) < 6:
print(__doc__, file=sys.stderr)
return 2
repository, group, version, signing = Path(sys.argv[1]), sys.argv[2], sys.argv[3], sys.argv[4]
signed = signing == "signed"
failed = False
for artifact in sys.argv[5:] + ["grpc-library"]:
directory = repository / group.replace(".", "/") / artifact / version
base = directory / f"{artifact}-{version}"
problems: list[str] = []
if artifact == "grpc-library":
expect(base.with_name(base.name + ".pom"), signed, problems)
expect(base.with_name(base.name + "-cyclonedx.json"), signed, problems)
else:
for suffix in (".jar", "-sources.jar", "-javadoc.jar", ".pom", ".module"):
expect(base.with_name(base.name + suffix), signed, problems)
pom, module = base.with_name(base.name + ".pom"), base.with_name(base.name + ".module")
if pom.is_file():
problems += [f"POM dependency without a version: {d}" for d in unversioned_pom(pom)]
if module.is_file():
problems += [f"module dependency without a version: {d}" for d in unversioned_module(module)]
if problems:
failed = True
print(f"{group}:{artifact}:{version}", file=sys.stderr)
for problem in problems:
print(f" - {problem}", file=sys.stderr)
else:
print(f"staged: {group}:{artifact}:{version}{' (signed)' if signed else ''}")
return 1 if failed else 0
if __name__ == "__main__":
sys.exit(main())