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`
This commit is contained in:
James Cox
2026-03-20 15:51:42 -05:00
parent c4b021f3b9
commit dfd7a19f5c
+14 -8
View File
@@ -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'
}
}
}