Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Gradle LessCss Plugin Build Status

A gradle plugin that compiles LESS files to CSS. Version 1.0-1.3.3 of the plugin uses LESS version 1.3.3.

This plugin helps to you to integrate the processing of LESS files into your automated build process without the need of installing node.js on the build server or adding the compiled CSS files to your version control system.


Add the plugin

Add artifact for the plugin to your Gradle buildscript dependencies in your build.gradle:

buildscript {
    repositories {
    dependencies {
        classpath 'de.obqo.gradle:gradle-lesscss-plugin:1.0-1.3.3'

Activate the plugin

apply plugin: 'lesscss'

Configure the plugin

lesscss {
    source = fileTree('src/main/less') {
        include 'style.less'
    dest = 'src/main/webapp/assets/css'
    compress = true

Run the plugin

The plugin adds two tasks to the build script: lesscss and (implicitly) cleanLesscss.

  • lesscss - compiles the specified LESS files from the source directory to CSS files in the dest directory
  • cleanLesscss - deletes completely the dest directory (be careful if there are other than generated CSS files in this directory)

You may optionally add a dependency for example for the war task by specifying

war {
    dependsOn 'lesscss'

Then everytime the war task is executed the lesscss task will be executed before.

That's it!


The lesscss object provides 3 properties for configuring the gradle-lesscss-plugin:

  • source (required) describes the LESS sources. The fileTree should refer to the LESS base directory ("src/main/less" in the example above), then include will select only the files to be compiled ("style.less" in the example). The value for include might be an Ant-style file pattern (see the section about File trees in the gradle user guide). Note: it is important to correctly set the base directory since all contained files (i.e. imported modules) will be accounted for determining whether the output CSS files are up-to-date or not.

  • dest (required) describes the target directory for the CSS files. This is either a string or a file object. The names of the generated CSS files are derived from the source files, thus compiling style.less results in style.css in the dest directory.

  • compress (optional, defaults to false) when set to true turns on compression of the created CSS files.


Main parts of the build configuration as well as two classes for running JS scripts with Rhino have been taken from Eric Wendelin's great gradle-js-plugin. Without his work the development of this plugin would have taken much longer (or would have possibly not even succeeded). Thanks Eric!


A gradle plugin for compiling LESS files into CSS files




No releases published


No packages published
You can’t perform that action at this time.