Class AbstractLesscController

All Implemented Interfaces:

public abstract class AbstractLesscController extends AppController

Subclass will compile and serve CSS from LESS files. For more information on LESS, please see Usually a developer would subclass this controller to trigger and compile in development environment, but the URI to CSS file would be ignored by the framework (configured in RouteConfig), so that a statically compiled version is served by a container or a web server.

This controller does not by itself compile LESS files. It shells out to a lessc compiler, which needs to be installed.

The controller will only compile LESS files if there have been any changes since the last invocation. If there has been no changes, it immediately serves the cached version of CSS compiled previously.

Example usage:

 public class BootstrapController extends AbstractLesscController {
        protected File getLessFile() {
            return new File("src/main/webapp/less/bootstrap.less");

   public class RouteConfig extends AbstractRouteConfig {
      public void init(AppContext appContext) {
The line in the RouteConfig ensures that the URI /bootstrap.css is ignored by the framework in every environment except "development". This is why the controller is triggering in development environment only.
igor on 4/28/14
  • Constructor Details

    • AbstractLesscController

      public AbstractLesscController()
  • Method Details

    • index

      public void index()
    • getLessFile

      protected abstract File getLessFile()
      Subclass should return a file handle pointing to the main Less file.
      file handle pointing to the main Less file
    • getLesscArguments

      protected String[] getLesscArguments()
      Subclass should override this method if they want to provide custom list of arguments to LessC compiler.
      custom list of arguments for LessC compiler.