From dfd7a19f5cdc52ac6ae55c5765ad78e8e25bc73c Mon Sep 17 00:00:00 2001 From: James Cox Date: Fri, 20 Mar 2026 15:24:05 -0500 Subject: [PATCH] fix(build): make frontend resources optional in test runs - Gradle packaging: - stop treating the default frontend dist path as a required input during `processResources` - include frontend assets only when the resolved dist directory actually exists - keep support for the explicit `-PfrontendDistDir=...` path used by the Docker build - CI stability: - restore backend-only Gradle runs in the reusable test workflow without requiring an Angular build first - prevent `processResources` from failing before backend tests execute when `booklore-ui/dist/...` is absent - Validation: - run `processResources` successfully with no frontend dist present - run `processResources` with a temporary `frontendDistDir` and confirm `static/index.html` is packaged - pass `git diff --check` --- booklore-api/build.gradle | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/booklore-api/build.gradle b/booklore-api/build.gradle index 80952d709..1c578470c 100644 --- a/booklore-api/build.gradle +++ b/booklore-api/build.gradle @@ -10,8 +10,9 @@ plugins { group = 'org.booklore' version = '0.0.1-SNAPSHOT' -def frontendDistDir = providers.gradleProperty('frontendDistDir') - .orElse("${rootDir}/../booklore-ui/dist/booklore/browser") +def defaultFrontendDistDir = file("${rootDir}/../booklore-ui/dist/booklore/browser") +def configuredFrontendDistDir = providers.gradleProperty('frontendDistDir') + .map { file(it) } java { toolchain { @@ -145,12 +146,17 @@ jacocoTestReport { } tasks.named('processResources') { - def frontendResourcesDir = providers.provider { file(frontendDistDir.get()) } - inputs.dir(frontendResourcesDir) - .withPropertyName('frontendDistDir') - .optional() - from(frontendResourcesDir) { - into 'static' + def frontendResourcesDir = configuredFrontendDistDir + .orElse(providers.provider { defaultFrontendDistDir }) + .get() + + inputs.property('frontendDistDir', frontendResourcesDir.absolutePath) + inputs.property('hasFrontendResources', frontendResourcesDir.exists()) + + if (frontendResourcesDir.exists()) { + from(frontendResourcesDir) { + into 'static' + } } }