옮겨 온 메시징 19개 모듈은 템플릿의 src/settings.gradle·build-logic· 카탈로그·registry에 기대고 있어 이 repo만으로는 빌드되지 않는다. repo 루트를 Gradle 루트로 하는 단독 빌드를 만든다. - build-logic/: grpc-library main 2e880c7의 줄인 사본(템플릿 22df3525에서 복사, 템플릿 2959eff0까지의 변경도 같은 내용)에서 gRPC BOM 규칙(ca.grpc-platform-module)만 뺐다. 배포 플러그인 ca.library-publishing과 서명 키 해석(SigningKeys)은 그대로다. 출처·뺀 것·고친 것은 build-logic/UPSTREAM.md. - settings.gradle·build.gradle·gradle.properties: group dev.cakit.messaging, 단계 태스크 ci·mainCheck·releaseCheck와 배포(release·releaseRehearsal·verifySigningKey)는 grpc-library와 같은 모양이다. 메시징만 다른 점: Buf가 없고, 성능 lane이 없고, mainCheck와 releaseCheck가 브로커 인증 증거 게이트 (verifyMessagingCertificationEvidence)를 부른다. 템플릿은 이 게이트를 따로 messaging-certification.yml로 돌렸다. 그 workflow는 지운다. - config/: registry 19행(source_path만 messaging/<leaf>로), 메시징 클래스만 남긴 SpotBugs 제외 목록, 이미지 셋(postgres-16, kafka, toxiproxy, 모두 digest 고정), checkstyle 사본. - gradle/libs.versions.toml: 메시징이 쓰는 항목만(avro, cloudevents, protobuf 4.33.2, toxiproxy, jmh)과 kafka-clients가 끌고 오는 취약 버전을 덮는 pinned-lz4-java·pinned-snappy-java. - 저장소 계약 테스트: MessagingPublicSurfaceContractTest(템플릿 app-bootstrap에서 이력째 옮김)와 새 MessagingSettingsOwnerContractTest (app.messaging 주인은 starter 하나)를 messaging-testkit의 repositoryContractTest lane에 둔다. check에 들어가 PR 단계에서 돈다. - messaging-kafka: 인증 manifest 경로를 새 배치로 고친다. 버린 대안: 계약 테스트를 build-logic 테스트로 두는 안. 빌드 플러그인 시험과 모듈 계약이 섞이고, 소스·build.gradle을 입력으로 선언하는 기존 lane 장치를 쓸 수 없다. 위험: 이 커밋 단독으로는 lockfile을 다시 쓰지 않았다(뒤 커밋에서 desktop에서 쓴다). 패키지는 아직 dev.caskeleton.messaging이다. 검증: desktop ./gradlew projects rc=0(19개 모듈 포함). Refs: design-docs repo-structure/05-library-repos.md 4·10.3·13.1절
316 lines
14 KiB
Groovy
316 lines
14 KiB
Groovy
import dev.caskeleton.buildlogic.java.JavaConventionsPlugin
|
|
import dev.caskeleton.buildlogic.publishing.SigningKeys
|
|
|
|
plugins {
|
|
id 'ca.architecture'
|
|
// Every strict lane belongs to a stage a workflow executes (.gitea/workflows). Without it a lane
|
|
// that fails closed can still run nowhere (template review 2026-11-03 RR-06-03).
|
|
id 'ca.strict-lane-stages'
|
|
// The release SBOM is published as an artifact of its own, `messaging-library`, next to the modules.
|
|
id 'maven-publish'
|
|
id 'signing'
|
|
// JMH benchmarks in messaging-kafka and messaging-testkit (`./gradlew :messaging:<leaf>:jmh`);
|
|
// never part of a gate. Declared here so the modules apply it by id at the catalog's version.
|
|
alias(libs.plugins.jmh) apply false
|
|
}
|
|
|
|
// The modules: every leaf the registry includes (settings.gradle). The family project `:messaging` is
|
|
// a folder, not a module.
|
|
def leaves = subprojects.findAll { it.childProjects.isEmpty() }
|
|
def leafPaths = leaves.collect { it.path }
|
|
|
|
// The root's coordinate is the release's: the SBOM artifact carries the version the modules carry.
|
|
group = providers.gradleProperty('libraryGroup').get()
|
|
def revision = JavaConventionsPlugin.sourceRevision(providers)
|
|
version = JavaConventionsPlugin.releaseVersion(providers) +
|
|
(revision == JavaConventionsPlugin.UNKNOWN_REVISION ? '-SNAPSHOT' : '')
|
|
// Captured here: inside a task's configuration `group` and `version` are the task's own properties.
|
|
def libraryCoordinates = [project.group.toString(), project.version.toString()]
|
|
|
|
tasks.register('resolveAndLockAll') {
|
|
group = 'build setup'
|
|
description = 'Regenerates dependency locks for every module (requires --write-locks).'
|
|
dependsOn leafPaths.collect { "${it}:resolveAndLockAll" }
|
|
}
|
|
|
|
tasks.register('verifyDependencyLocks') {
|
|
group = 'verification'
|
|
description = 'Fails when a module resolves something its strict lockfile does not list.'
|
|
dependsOn leafPaths.collect { "${it}:verifyDependencyLocks" }
|
|
}
|
|
|
|
tasks.register('checkAll') {
|
|
group = 'verification'
|
|
description = 'Runs every module check.'
|
|
dependsOn leafPaths.collect { "${it}:check" }
|
|
}
|
|
|
|
tasks.register('qualityCheck') {
|
|
group = 'verification'
|
|
description = 'Runs production-bytecode static analysis for every module.'
|
|
dependsOn leafPaths.collect { "${it}:qualityCheck" }
|
|
}
|
|
|
|
// SpotBugs + FindSecBugs over the test source sets (config/spotbugs/exclude-test.xml). The modules are
|
|
// small enough for the pull-request stage to afford it, so it joins `ci`.
|
|
tasks.register('testQualityCheck') {
|
|
group = 'verification'
|
|
description = 'Runs test-code static analysis for every module.'
|
|
dependsOn leafPaths.collect { "${it}:testQualityCheck" }
|
|
}
|
|
|
|
// build-logic is a copy of the template's convention plugins (build-logic/UPSTREAM.md); its own
|
|
// TestKit and unit tests keep the copy honest when it is changed here.
|
|
tasks.register('buildLogicTest') {
|
|
group = 'verification'
|
|
description = 'Runs the included build-logic build\'s tests.'
|
|
dependsOn gradle.includedBuild('build-logic').task(':test')
|
|
}
|
|
|
|
// The pull-request stage (pr.yml). messaging-testkit's `check` includes its repository-contract lane
|
|
// (the public-surface and settings-owner contracts read every module's sources and build script), so
|
|
// a dependency-scope or ownership drift stops a merge.
|
|
tasks.register('ci') {
|
|
group = 'verification'
|
|
description = 'The pull-request stage: module checks, architecture, static analysis, locks and build-logic tests.'
|
|
dependsOn tasks.named('checkAll')
|
|
dependsOn tasks.named('qualityCheck')
|
|
dependsOn tasks.named('testQualityCheck')
|
|
dependsOn tasks.named('verifyDependencyLocks')
|
|
// architectureCheck, not only the direction gate: it also runs verifyNoIgnoredSourcePackages.
|
|
dependsOn tasks.named('architectureCheck')
|
|
dependsOn tasks.named('buildLogicTest')
|
|
}
|
|
|
|
// Every module's integration lanes, all Testcontainers: messaging-kafka's broker certification lane
|
|
// (Kafka behind Toxiproxy), messaging-reliability-jdbc-postgresql's outbox, inbox and admin-journal
|
|
// contracts against PostgreSQL, and the starter's assembled round trip (Kafka and PostgreSQL). Needs a
|
|
// container runtime.
|
|
tasks.register('integrationCheck') {
|
|
group = 'verification'
|
|
description = 'Runs every module integration test lane. Needs a container runtime.'
|
|
dependsOn leafPaths.collect { "${it}:integrationTestLaneCheck" }
|
|
}
|
|
|
|
// The certification gate: the scenarios the committed manifest claims are the ones this run of the
|
|
// certification lane proved against a live broker (messaging-kafka/build.gradle). Editing the
|
|
// manifest by hand fails it; running the lane writes the produced copy to compare.
|
|
def certificationGate = ':messaging:messaging-kafka:verifyMessagingCertificationEvidence'
|
|
|
|
// The main-branch stage (main.yml): the pull-request stage again on the merged commit, plus the lanes
|
|
// that start containers and the certification gate. The template ran the gate in a workflow of its own
|
|
// (messaging-certification.yml, weekly and on messaging paths); here every main push and the nightly
|
|
// run run it. No module has a performance lane: the JMH benchmarks are not a gate.
|
|
tasks.register('mainCheck') {
|
|
group = 'verification'
|
|
description = 'The main-branch stage: ci, integrationCheck and the broker certification gate.'
|
|
dependsOn tasks.named('ci')
|
|
dependsOn tasks.named('integrationCheck')
|
|
dependsOn certificationGate
|
|
}
|
|
|
|
// ---------------------------------------------------------------- release (release.yml)
|
|
|
|
def sbomFile = layout.buildDirectory.file("release/messaging-library-${version}-cyclonedx.json")
|
|
|
|
tasks.register('verifyReleaseVersion') {
|
|
group = 'verification'
|
|
description = 'Fails unless this build names a release version and the commit it was built from.'
|
|
def releaseVersion = libraryCoordinates[1]
|
|
doLast {
|
|
if (releaseVersion.endsWith('-SNAPSHOT')) {
|
|
throw new GradleException("No commit id (-PgitRevision, GIT_SHA or GITHUB_SHA): ${releaseVersion} is not a release.")
|
|
}
|
|
if (releaseVersion == '0.0.1') {
|
|
throw new GradleException('No release version: run with RELEASE_TAG=vX.Y.Z (release.yml) or -PreleaseVersion.')
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.register('releaseSbom', Exec) {
|
|
group = 'release'
|
|
description = 'Writes the CycloneDX SBOM of the published modules from their lockfiles (Trivy).'
|
|
outputs.file(sbomFile)
|
|
outputs.upToDateWhen { false }
|
|
commandLine 'bash', file('scripts/release/sbom.sh'), sbomFile.get().asFile
|
|
}
|
|
|
|
tasks.register('dependencyVulnerabilityScan', Exec) {
|
|
group = 'verification'
|
|
description = 'Fails on a HIGH or CRITICAL dependency vulnerability or any CISA KEV match (Trivy).'
|
|
mustRunAfter tasks.named('releaseSbom')
|
|
def reports = layout.buildDirectory.dir('release/vulnerability')
|
|
commandLine 'bash', file('scripts/release/vulnerability-scan.sh'), reports.get().asFile
|
|
}
|
|
|
|
// The tag-only stage: the hermetic lanes of every module, the integration lanes, the broker
|
|
// certification gate (a release claims what the support matrix says, so the evidence is re-proved on
|
|
// the tagged commit), the version check, the SBOM and the dependency gate.
|
|
tasks.register('releaseCheck') {
|
|
group = 'verification'
|
|
description = 'The release stage before publishing: certification gate, integration lanes, version, SBOM, dependency gate.'
|
|
dependsOn tasks.named('verifyReleaseVersion')
|
|
dependsOn leafPaths.collect { "${it}:testLaneCheck" }
|
|
dependsOn tasks.named('integrationCheck')
|
|
dependsOn certificationGate
|
|
dependsOn tasks.named('releaseSbom')
|
|
dependsOn tasks.named('dependencyVulnerabilityScan')
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
sbom(MavenPublication) {
|
|
artifactId = 'messaging-library'
|
|
artifact(sbomFile) {
|
|
classifier = 'cyclonedx'
|
|
extension = 'json'
|
|
builtBy tasks.named('releaseSbom')
|
|
}
|
|
pom {
|
|
name = 'messaging-library'
|
|
description = 'CycloneDX SBOM of the messaging-library modules of this version.'
|
|
url = providers.gradleProperty('repositoryUrl')
|
|
packaging = 'pom'
|
|
}
|
|
}
|
|
}
|
|
repositories {
|
|
maven {
|
|
name = 'gitea'
|
|
url = providers.gradleProperty('packagesUrl')
|
|
credentials(HttpHeaderCredentials) {
|
|
name = 'Authorization'
|
|
value = "token ${providers.environmentVariable('PACKAGE_TOKEN').getOrElse('')}"
|
|
}
|
|
authentication {
|
|
header(HttpHeaderAuthentication)
|
|
}
|
|
}
|
|
maven {
|
|
name = 'staging'
|
|
url = layout.buildDirectory.dir('staging-repository')
|
|
}
|
|
}
|
|
}
|
|
|
|
// The armoured key, or the base64 of the armoured file (the usual way to keep it in a CI secret).
|
|
def signingKey = SigningKeys.armoured(providers.environmentVariable('SIGNING_KEY').getOrElse(''))
|
|
|
|
// Before anything is signed: the secret's shape, that gpg imports it as the release key and that
|
|
// SIGNING_PASSWORD signs with it, printing no part of either. Gradle's signing reports every one of
|
|
// these as "Could not read PGP secret key" (v1.0.0 release run 9); this says which. A key other
|
|
// than the release key passes with -PsigningKeyFingerprint=<its fingerprint> (a rehearsal key).
|
|
// gpg reads only a passphrase's first line and Gradle the whole value, so the task then signs a few
|
|
// bytes with Gradle's own signatory: the verdict is the one the Sign tasks would reach.
|
|
tasks.register('verifySigningKey', Exec) {
|
|
group = 'verification'
|
|
description = 'Checks SIGNING_KEY and SIGNING_PASSWORD without printing them (scripts/release/check-signing-key.sh).'
|
|
outputs.upToDateWhen { false }
|
|
ignoreExitValue = true
|
|
commandLine 'bash', file('scripts/release/check-signing-key.sh'),
|
|
providers.gradleProperty('signingKeyFingerprint').getOrElse('')
|
|
def signed = !signingKey.isBlank()
|
|
doLast {
|
|
boolean scriptPassed = executionResult.get().exitValue == 0
|
|
boolean gradlePassed = !signed
|
|
String verdict = 'skipped: no SIGNING_KEY'
|
|
if (signed) {
|
|
try {
|
|
signing.signatory.sign(new ByteArrayInputStream('signing check'.bytes), OutputStream.nullOutputStream())
|
|
gradlePassed = true
|
|
verdict = 'ok'
|
|
} catch (Exception failure) {
|
|
// Exception text only: BouncyCastle names what failed (checksum mismatch, a tag), never the key.
|
|
def cause = failure.cause ? " (${failure.cause.class.simpleName}: ${failure.cause.message})" : ''
|
|
verdict = "failed: ${failure.message}${cause}"
|
|
}
|
|
}
|
|
logger.lifecycle("signing as Gradle's Sign tasks do (in-memory key): ${verdict}")
|
|
if (!scriptPassed || !gradlePassed) {
|
|
throw new GradleException('verifySigningKey: the signing secrets would not sign; the PROBLEM lines above say why.')
|
|
}
|
|
}
|
|
}
|
|
tasks.withType(Sign).configureEach {
|
|
mustRunAfter tasks.named('verifySigningKey')
|
|
}
|
|
if (!signingKey.isBlank()) {
|
|
signing {
|
|
useInMemoryPgpKeys(signingKey, providers.environmentVariable('SIGNING_PASSWORD').getOrElse(''))
|
|
sign publishing.publications.sbom
|
|
}
|
|
}
|
|
|
|
tasks.withType(PublishToMavenRepository).configureEach {
|
|
mustRunAfter tasks.named('releaseCheck')
|
|
if (name.endsWith('ToGiteaRepository')) {
|
|
def signed = !signingKey.isBlank()
|
|
def token = providers.environmentVariable('PACKAGE_TOKEN').getOrElse('')
|
|
doFirst {
|
|
if (!signed) {
|
|
throw new GradleException('SIGNING_KEY is not set; refusing to publish unsigned files to Gitea.')
|
|
}
|
|
if (token.isBlank()) {
|
|
throw new GradleException('PACKAGE_TOKEN is not set; Gitea\'s job token cannot publish packages.')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Everything release.yml does up to the upload, into build/staging-repository: what `release` would
|
|
// publish, checked file by file. Needs no secret; with SIGNING_KEY set it also checks every .asc.
|
|
tasks.register('releaseRehearsal') {
|
|
group = 'release'
|
|
description = 'releaseCheck, then publishes every module and the SBOM to build/staging-repository and checks the files.'
|
|
dependsOn tasks.named('releaseCheck')
|
|
if (!signingKey.isBlank()) {
|
|
dependsOn tasks.named('verifySigningKey')
|
|
}
|
|
dependsOn tasks.named('publishAllPublicationsToStagingRepository')
|
|
dependsOn leafPaths.collect { "${it}:publishAllPublicationsToStagingRepository" }
|
|
def staging = layout.buildDirectory.dir('staging-repository')
|
|
def artifacts = leaves.collect { it.name }
|
|
def coordinates = libraryCoordinates
|
|
def signed = !signingKey.isBlank()
|
|
def checker = file('scripts/release/check-staging.py')
|
|
doLast {
|
|
def command = ['python3', checker.path, staging.get().asFile.path, coordinates[0], coordinates[1],
|
|
signed ? 'signed' : 'unsigned'] + artifacts
|
|
def process = command.execute()
|
|
process.waitForProcessOutput(System.out, System.err)
|
|
if (process.exitValue() != 0) {
|
|
throw new GradleException('releaseRehearsal: the staged release is incomplete (see above).')
|
|
}
|
|
}
|
|
}
|
|
|
|
// The release: releaseCheck, then every module and the SBOM to Gitea Packages, then an anonymous read
|
|
// of each module's metadata. release.yml runs this one task on a vX.Y.Z tag.
|
|
tasks.register('release') {
|
|
group = 'release'
|
|
description = 'releaseCheck, publish to Gitea Packages, then verify the version is readable anonymously.'
|
|
dependsOn tasks.named('releaseCheck')
|
|
dependsOn tasks.named('verifySigningKey')
|
|
dependsOn tasks.named('publishAllPublicationsToGiteaRepository')
|
|
dependsOn leafPaths.collect { "${it}:publishAllPublicationsToGiteaRepository" }
|
|
def url = providers.gradleProperty('packagesUrl')
|
|
def artifacts = leaves.collect { it.name } + ['messaging-library']
|
|
def coordinates = libraryCoordinates
|
|
def verifier = file('scripts/release/verify-published.sh')
|
|
doLast {
|
|
def command = ['bash', verifier.path, url.get(), coordinates[0], coordinates[1]] + artifacts
|
|
def process = command.execute()
|
|
process.waitForProcessOutput(System.out, System.err)
|
|
if (process.exitValue() != 0) {
|
|
throw new GradleException('release: a published module is not readable anonymously (see above).')
|
|
}
|
|
}
|
|
}
|
|
|
|
// The stages a strict lane may belong to, executed by .gitea/workflows as `./gradlew <stage>` from the
|
|
// repository root. releaseCheck may run on a tag push only.
|
|
strictLaneStages {
|
|
stage ':ci', ':mainCheck', ':releaseCheck'
|
|
workflowDirectory = layout.projectDirectory.dir('.gitea/workflows')
|
|
}
|