fix(docker): skip frontend Gradle tasks when SKIP_FRONTEND is set
Add onlyIf predicate to installFrontendDependencies and buildFrontend tasks so they are skipped when SKIP_FRONTEND env var is present. This fixes the Docker multi-stage build which failed because Gradle validated input files (package.json, package-lock.json) that don't exist in the builder stage. Also moved the skipFrontend variable definition before task registration for cleaner code organization. Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
@@ -35,7 +35,11 @@ def frontendDir = file('../frontend')
|
||||
def frontendDistDir = file('../frontend/dist/frontend/browser')
|
||||
def springStaticDir = file('src/main/resources/static')
|
||||
|
||||
// Skip frontend build tasks when building inside Docker (frontend already built in Stage 1)
|
||||
def skipFrontend = project.hasProperty('skipFrontend') || System.getenv('SKIP_FRONTEND') != null
|
||||
|
||||
tasks.register('installFrontendDependencies', Exec) {
|
||||
onlyIf { !skipFrontend }
|
||||
workingDir frontendDir
|
||||
|
||||
inputs.file(file('../frontend/package.json'))
|
||||
@@ -50,6 +54,7 @@ tasks.register('installFrontendDependencies', Exec) {
|
||||
}
|
||||
|
||||
tasks.register('buildFrontend', Exec) {
|
||||
onlyIf { !skipFrontend }
|
||||
dependsOn 'installFrontendDependencies'
|
||||
workingDir frontendDir
|
||||
|
||||
@@ -66,9 +71,6 @@ tasks.register('buildFrontend', Exec) {
|
||||
}
|
||||
}
|
||||
|
||||
// Skip frontend build tasks when building inside Docker (frontend already built in Stage 1)
|
||||
def skipFrontend = project.hasProperty('skipFrontend') || System.getenv('SKIP_FRONTEND') != null
|
||||
|
||||
tasks.register('copyFrontend', Copy) {
|
||||
onlyIf { !skipFrontend }
|
||||
dependsOn 'buildFrontend'
|
||||
|
||||
Reference in New Issue
Block a user