Skip to content
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,27 @@ class VaadinSmokeTest : AbstractGradleTest() {
assertContains(result.output, "Calculating task graph as no cached configuration is available for tasks: vaadinBuildFrontend")
}

@Test
fun testWarPackaging_configurationCache_productionMode() {
// Regression test for https://github.com/vaadin/flow/issues/24794
// In production mode the token-restore action is attached to the
// Jar/War packaging task. If that action captures the Project, the
// configuration cache cannot serialize the War task and the build
// fails. The existing config-cache tests only run vaadinBuildFrontend,
// so they never exercise the packaging task; this test does.

// Create frontend folder, that will otherwise be created by the first
// execution, invalidating the cache on the second run
testProject.newFolder("src/main/frontend")

val result = testProject.build("--configuration-cache", "-Pvaadin.productionMode", "war")
result.expectTaskSucceded("war")
assertContains(result.output, "Configuration cache entry stored")

val result2 = testProject.build("--configuration-cache", "-Pvaadin.productionMode", "war", checkTasksSuccessful = false)
assertContains(result2.output, "Reusing configuration cache")
}

private fun enableHilla() {
testProject.newFolder(FrontendUtils.DEFAULT_FRONTEND_DIR)
testProject.newFile(FrontendUtils.DEFAULT_FRONTEND_DIR + "index.ts")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ public class FlowPlugin : Plugin<Project> {
// this will also catch the War task since it extends from Jar
project.tasks.withType(Jar::class.java) { task: Jar ->
task.dependsOn("vaadinBuildFrontend")
// Restore the production token before packaging in
// case it was deleted by a previous build's cleanup.
task.doFirst {
val svc = (project.tasks.getByName("vaadinBuildFrontend")
as VaadinBuildFrontendTask).getTokenService().orNull
svc?.ensureToken()
}
}
} else if (config.alwaysExecutePrepareFrontend.get()) {
// In development mode, vaadinPrepareFrontend is not
Expand Down Expand Up @@ -150,6 +143,13 @@ public class FlowPlugin : Plugin<Project> {
buildFrontendTask.usesService(tokenService)
project.tasks.withType(Jar::class.java) { task: Jar ->
task.usesService(tokenService)
// Restore the production token before packaging in
// case it was deleted by a previous build's cleanup.
// Capture the service provider rather than the Project so
// the action stays compatible with the configuration cache.
task.doFirst {
tokenService.get().ensureToken()
}
}
}
}
Expand Down
Loading