Gradle LessCss Plugin

A Gradle plugin for compiling LESS files to CSS files.

License

License

Categories

Categories

Gradle Build Tools
GroupId

GroupId

de.obqo.gradle
ArtifactId

ArtifactId

gradle-lesscss-plugin
Last Version

Last Version

1.0-1.3.3
Release Date

Release Date

Type

Type

jar
Description

Description

Gradle LessCss Plugin
A Gradle plugin for compiling LESS files to CSS files.
Project URL

Project URL

https://github.com/obecker/gradle-lesscss-plugin
Source Code Management

Source Code Management

https://github.com/obecker/gradle-lesscss-plugin

Download gradle-lesscss-plugin

How to add to project

<!-- https://jarcasting.com/artifacts/de.obqo.gradle/gradle-lesscss-plugin/ -->
<dependency>
    <groupId>de.obqo.gradle</groupId>
    <artifactId>gradle-lesscss-plugin</artifactId>
    <version>1.0-1.3.3</version>
</dependency>
// https://jarcasting.com/artifacts/de.obqo.gradle/gradle-lesscss-plugin/
implementation 'de.obqo.gradle:gradle-lesscss-plugin:1.0-1.3.3'
// https://jarcasting.com/artifacts/de.obqo.gradle/gradle-lesscss-plugin/
implementation ("de.obqo.gradle:gradle-lesscss-plugin:1.0-1.3.3")
'de.obqo.gradle:gradle-lesscss-plugin:jar:1.0-1.3.3'
<dependency org="de.obqo.gradle" name="gradle-lesscss-plugin" rev="1.0-1.3.3">
  <artifact name="gradle-lesscss-plugin" type="jar" />
</dependency>
@Grapes(
@Grab(group='de.obqo.gradle', module='gradle-lesscss-plugin', version='1.0-1.3.3')
)
libraryDependencies += "de.obqo.gradle" % "gradle-lesscss-plugin" % "1.0-1.3.3"
[de.obqo.gradle/gradle-lesscss-plugin "1.0-1.3.3"]

Dependencies

test (1)

Group / Artifact Type Version
org.spockframework : spock-core jar 0.6-groovy-1.8

Project Modules

There are no modules declared in this project.

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.

Usage

Add the plugin

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

buildscript {
    repositories {
        mavenCentral()
    }
    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!

Options

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.

Acknowledgments

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!

Versions

Version
1.0-1.3.3