fix(build): package frontend assets through Gradle resources
- Backend packaging: - make `processResources` include the built frontend dist as an explicit `static/` resource input instead of relying on a manual copy into Gradle's output directory - keep `bootJar` as the source of truth for bundling `static/index.html` into the application jar - Docker build: - pass the frontend dist location into Gradle with `-PfrontendDistDir=/tmp/frontend-dist` - remove the ad hoc copy into `build/resources/main/static` before `bootJar` - Validation: - verify `processResources` emits `build/resources/main/static/index.html` when given a frontend dist directory - keep `git diff --check` clean for the touched packaging files
This commit is contained in:
+1
-4
@@ -24,11 +24,8 @@ RUN --mount=type=cache,target=/home/gradle/.gradle \
|
|||||||
COPY booklore-api/ ./
|
COPY booklore-api/ ./
|
||||||
COPY --from=frontend-build /workspace/booklore-ui/dist/booklore/browser /tmp/frontend-dist
|
COPY --from=frontend-build /workspace/booklore-ui/dist/booklore/browser /tmp/frontend-dist
|
||||||
|
|
||||||
RUN mkdir -p build/resources/main/static && \
|
|
||||||
cp -r /tmp/frontend-dist/. build/resources/main/static/
|
|
||||||
|
|
||||||
RUN --mount=type=cache,target=/home/gradle/.gradle \
|
RUN --mount=type=cache,target=/home/gradle/.gradle \
|
||||||
./gradlew --no-daemon bootJar
|
./gradlew --no-daemon -PfrontendDistDir=/tmp/frontend-dist bootJar
|
||||||
|
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
jar_path="$(find build/libs -maxdepth 1 -name '*.jar' ! -name '*plain.jar' | head -n 1)"; \
|
jar_path="$(find build/libs -maxdepth 1 -name '*.jar' ! -name '*plain.jar' | head -n 1)"; \
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ plugins {
|
|||||||
group = 'org.booklore'
|
group = 'org.booklore'
|
||||||
version = '0.0.1-SNAPSHOT'
|
version = '0.0.1-SNAPSHOT'
|
||||||
|
|
||||||
|
def frontendDistDir = providers.gradleProperty('frontendDistDir')
|
||||||
|
.orElse("${rootDir}/../booklore-ui/dist/booklore/browser")
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain {
|
toolchain {
|
||||||
languageVersion = JavaLanguageVersion.of(25)
|
languageVersion = JavaLanguageVersion.of(25)
|
||||||
@@ -141,6 +144,16 @@ jacocoTestReport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.named('processResources') {
|
||||||
|
def frontendResourcesDir = providers.provider { file(frontendDistDir.get()) }
|
||||||
|
inputs.dir(frontendResourcesDir)
|
||||||
|
.withPropertyName('frontendDistDir')
|
||||||
|
.optional()
|
||||||
|
from(frontendResourcesDir) {
|
||||||
|
into 'static'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bootRun {
|
bootRun {
|
||||||
def debug = System.getenv('REMOTE_DEBUG_ENABLED')
|
def debug = System.getenv('REMOTE_DEBUG_ENABLED')
|
||||||
if (debug.equals("true")) {
|
if (debug.equals("true")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user