Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions libs/gretty/src/main/groovy/org/akhikhl/gretty/GrettyPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,24 @@ class GrettyPlugin implements Plugin<Project> {
group = 'gretty'
description = 'Copies webAppDir of this web-app and all overlays (if any) to ${buildDir}/inplaceWebapp'

def getInplaceMode = {
project.tasks.findByName('appRun').effectiveInplaceMode
}

// Compute effective inplace mode from gretty extension at configuration time.
// addTasks() is invoked from afterProjectEvaluate, so the extension is fully configured here.
// Using an eagerly-computed String avoids capturing the project instance inside task closures,
// which is required for Gradle configuration cache compatibility ( issue #332)
String inplaceMode = project.gretty.webAppConfig.inplaceMode ?: 'soft'
// We should track changes in inplaceMode value or plugin would show UP-TO-DATE for this task
// even if inplaceMode was changed
inputs.property('inplaceMode', getInplaceMode)
inputs.property('inplaceMode', inplaceMode)

onlyIf { getInplaceMode() != 'hard' }
onlyIf { inplaceMode != 'hard' }

// Attention: call order is important here! Overlay files must be copied prior to this web-app files.

for (String overlay in project.gretty.overlays) {
Project overlayProject = project.project(overlay)
dependsOn { overlayProject.tasks.findByName('prepareInplaceWebAppFolder') }
// Use a string-based task path instead of a Project-capturing closure so that this
// dependsOn declartion is compatible with the Gradle configuration cache ( issue #332)
dependsOn ":${overlay}:prepareInplaceWebAppFolder"
from "${overlayProject.buildDir}/inplaceWebapp"
}

Expand Down
Loading