LessWicketApplicationInstantiator.javalesscss-java compiler into Wicket's application lifecycle: it locates .less source files on the classpath, compiles them to CSS on the filesystem, mounts the compiled CSS as a versioned Wicket resource (using LessResourceReference), and — in development mode — registers filesystem watchers that automatically recompile when any .less source file changes. The compiled CSS filename includes the server startup timestamp as a cache-busting version marker (projectforge-version-{timestamp}.css).The class implements Serializable and maintains a static instance field. During Wicket application startup, an instance is created with the source .less path, target .css path, and a filesystem baseDir. The instantiate() method is called, which:
ClassPathResourcecompileCss flag — useful for production where CSS should be pre-compiled)LessResourceReference for the compiled outputWhen WebConfiguration.isDevelopmentMode() returns true, the class leverages Wicket's built-in IModificationWatcher infrastructure to monitor the main LESS source and all its @import dependencies. When any file changes, the watcher triggers a recompilation — developers see CSS changes immediately without restarting the server. The watcher covers the entire transitive import graph via mainLessSource.getImports().values().
The method encodePathWithCachingStrategy replaces .css with -version-{startTime}.css in the resource path. The timestamp (WicketApplication.getStartTime()) changes on each server restart, effectively busting browser caches after deployments. The prefix -version- is deliberately different from Wicket's default -ver- to avoid collisions with Wicket's internal resource versioning.
The static method renderCompiledCssResource(IHeaderResponse) is the entry point called by page templates to include the compiled CSS in HTML headers. It renders a CssReferenceHeaderItem pointing to the mounted resource. If the instantiator hasn't been initialized (the static instance is null), it logs an error — this is a fail-safe for pages rendered before the LESS compilation completes.
| Commit | What changed |
|---|---|
868d6abb7 through 4a6390e11 | Six commits spanning copyright year updates (2021→2026) and a Wicket 8 migration merge (4548710df). The copyright updates follow the annual header sweep pattern. The Wicket 8 migration commit (4a6390e11) is a merge from feature/wicket8 into develop — while the merge diff itself may not show changes in this specific file, the branch brought significant API changes across the wicket module. The class logic itself has been stable; all history entries are infrastructure changes rather than feature modifications. |