Skip to content

fix: delete flow-build-info.json after Maven session via AbstractMavenLifecycleParticipant#23945

Open
mcollovati wants to merge 1 commit intomainfrom
issues/21021-flowbuildinfo_deleteOnExit-maven
Open

fix: delete flow-build-info.json after Maven session via AbstractMavenLifecycleParticipant#23945
mcollovati wants to merge 1 commit intomainfrom
issues/21021-flowbuildinfo_deleteOnExit-maven

Conversation

@mcollovati
Copy link
Collaborator

BuildFrontendUtil.updateBuildFile() calls deleteOnExit() on the production token file, but this never fires when using the Maven Daemon (mvnd) because the JVM stays alive between builds. As a result, flow-build-info.json with productionMode: true persists in target/classes/META-INF/VAADIN/config/ and causes incorrect production-mode behavior when starting the app from the IDE.

Adds FlowLifecycleParticipant, an AbstractMavenLifecycleParticipant that hooks into afterSessionEnd() to delete the token file after every build session. BuildFrontendMojo stores the resolved token file path in a Maven project property so the participant always uses the correct path even when resourceOutputDirectory is user-configured.

AbstractMavenLifecycleParticipant only activates when the plugin is declared as a Maven extension, so users must add
<extensions>true</extensions> to the plugin declaration in their pom.xml to benefit from this fix. The existing deleteOnExit() call acts as a transparent fallback for projects that do not opt in.

Fixes #21021

…nLifecycleParticipant

`BuildFrontendUtil.updateBuildFile()` calls `deleteOnExit()` on the
production token file, but this never fires when using the Maven Daemon
(mvnd) because the JVM stays alive between builds. As a result,
`flow-build-info.json` with `productionMode: true` persists in
`target/classes/META-INF/VAADIN/config/` and causes incorrect
production-mode behavior when starting the app from the IDE.

Adds `FlowLifecycleParticipant`, an `AbstractMavenLifecycleParticipant`
that hooks into `afterSessionEnd()` to delete the token file after every
build session. `BuildFrontendMojo` stores the resolved token file path
in a Maven project property so the participant always uses the correct
path even when `resourceOutputDirectory` is user-configured.

`AbstractMavenLifecycleParticipant` only activates when the plugin is
declared as a Maven extension, so users must add
`<extensions>true</extensions>` to the plugin declaration in their
`pom.xml` to benefit from this fix. The existing `deleteOnExit()` call
acts as a transparent fallback for projects that do not opt in.

Fixes #21021
@mcollovati mcollovati force-pushed the issues/21021-flowbuildinfo_deleteOnExit-maven branch from c51d5b5 to 5fbab14 Compare March 18, 2026 17:31
@sonarqubecloud
Copy link

@github-actions
Copy link

Test Results

 1 388 files  ±0   1 388 suites  ±0   1h 25m 48s ⏱️ -11s
 9 927 tests ±0   9 856 ✅ ±0  71 💤 ±0  0 ❌ ±0 
10 400 runs  ±0  10 320 ✅ ±0  80 💤 ±0  0 ❌ ±0 

Results for commit 5fbab14. ± Comparison against base commit 718a053.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

consider alternative strategy for removing the tokenfile in maven plugin

2 participants