Skip to content

i-net-software/jlessc

Repository files navigation

JLessC

Build Status License Coverage Status Maven JitPack

JLessC is a Less CSS compiler written completely in Java (pure Java). It does not need any additional libraries at runtime (no JavaScript, no ANTLR). The main target of the project is performance and compatibility to Bootstrap.

Required Java Version

JLessC requires Java SE 8 or higher. It is tested with Java 8, 9, 10 and 11 on travis-ci.org. If you need support for Java 7 then you can use the old version 1.5.

Add Dependency

Gradle users should add the library using the following dependency:

dependencies {
    compile 'de.inetsoftware:jlessc:+'
}

If you want to test a snapshot version with the latest bug fixes, then add the snapshot repository:

repositories {
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
    mavenCentral() // or any other repository that you use
}

Or use on the fly snapshots from JitPack.

repositories {
    mavenCentral()
    maven { url 'https://jitpack.io' } // for snapshots
}
dependencies {
    compile 'com.github.i-net-software:jlessc:master-SNAPSHOT'
}

Maven users should add the library using the following dependency:

<dependency>
  <groupId>de.inetsoftware</groupId>
  <artifactId>jlessc</artifactId>
  <version>RELEASE</version>
</dependency>

Usage

Check out the sources or download the binary and add it to your Java project. The following code sequence shows a sample usage:

import com.inet.lib.less.Less;
...

// Compile Less data to CSS output
String css = Less.compile( null, "@bgcol: red; #row { background-color: @bgcol; }", true );

API details can be found in the source of the Less class.

Benchmark

JLessC runs a benchmark test on the Travis build system using different less compilers. We always use the latest version of every compiler. We measure the compile time of the Bootstrap sample in our test suite. The table shows a result for Java SE 8. Of course the values can change over the time.

Tool Time
JLessC ~400 ms
less.js via Exec call to nodeJS ~850 ms
Official LESS CSS Compiler for Java ~4400 ms
LESS Engine ~10800 ms

Alternative libraries

Reference usage

We use JLessC in our reporting software i-net Clear Reports and PDF file comparer i-net PDFC for user customized themes.