About

The LessCSS Compiler is a Java library which compiles Less source files to the CSS code.

From Less website:

Less is a CSS pre-processor, meaning that it extends the CSS language, adding features that allow variables, mixins, functions and many other techniques that allow you to make CSS that is more maintainable, themable and extendable.

Compatibility

The compiler is compatible with version 1.7.5. The library is based on the official Less JavaScript compiler adapted to the Rhino engine.

Restrictions:

Requirements

The compiler to run requires:

Concept

The idea for the LessCompilerImpl class was based on the lesscss-java library by Marcel Overdijk.

License

The plugin is distributed under open source and commercial friendly "BSD 3-Clause" license:

Copyright (c) 2015, Adam Gabryƛ
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met: 
1. Redistributions of source code must retain the above copyright notice, this 
list of conditions and the following disclaimer. 
2. Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation and/or 
other materials provided with the distribution. 
3. Neither the name of the gabrys.biz nor the names of its contributors may be 
used to endorse or promote products derived from this software without specific 
prior written permission. 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Download

You can download the compiler from docs pages or using various dependency management tools:

Example for Maven:

<project>
   ...
   <dependencies>
      <dependency>
         <groupId>biz.gabrys.lesscss</groupId>
         <artifactId>compiler</artifactId>
         <version>1.2.2</version>
      </dependency>
      ...
   <dependencies>
   ...
</project>

Usage

How to compile a source file:

// create compiler & source file
LessCompiler compiler = new LessCompilerImpl();
File source = new File("/less/file.less");

// compile file with default options
String cssCode = compiler.compile(source); 

// set custom option: minify CSS code
CompilerOptions options = new CompilerOptionsBuilder().setMinified(true).create();
String cssMinifiedCode = compiler.compile(source, options);

Versions

LATEST docs - the newest version under development

List of all available releases: 1.2.2, 1.2.1, 1.2, 1.1, 1.0.

Version Changelog
1.2.2
(docs)

Bugs:

  • Fixed support for data-uri function
1.2.1
(docs)

Bugs:

  • Fixed quality flaws
1.2
(docs)

Bugs:

1.1
(docs)

Bugs:

  • Fixed quality flaws
1.0
(docs)

Initial release