Fork me on GitHub


This document is intended to provide instructions for using the LessCSS Maven Plugin.

In order for this discussion to be useful, it's critical to cover two topics:

  1. Configuring your project's pom.xml to run the plugin during the project's build cycle
  2. Invoking the plugin from the command-line

Configuring Plugin

By tying the goals of the plugin to a phase in the build cycle, the specified goals will run each time that phase of the build cycle is executed. Doing this can make it easier to add the plugin to your project, because it eliminates the need to run the plugin standalone.

To bind the compile goal of the LessCSS Maven Plugin to a phase in the build cycle, you will need to add the execution tag with the goal set to compile. Optionally, you can bind the plugin to a different build phase by using the phase option. For instance, using process-sources in the phase option will force the compile goal to run each time this phase of the build cycle occurs.

For a complete list of the available configuration options see lesscss:compile goal overview page.

                  <phase>process-sources</phase> <!-- When omitted defaults to 'generate-sources' -->
                     <!-- put your configurations here -->

If you want to use snapshot, then you need to add the repository to your pom.xml:

      <name>Sonatype's SNAPSHOT repository</name>

Invoke from the command-line

The goals for the LessCSS Maven Plugin are bound to their respective phases in the build lifecycle. So to compile your sources, you need only to tell Maven until which lifecycle to execute. The following will compile your sources:

mvn compile

You can also compile Less sources by execute only this plugin:

mvn biz.gabrys.maven.plugins:lesscss-maven-plugin:compile

This plugin supports watch mode, which blocks thread and runs compile goal every X seconds (see configuration options).

mvn biz.gabrys.maven.plugins:lesscss-maven-plugin:compile