JorgeGRC JorgeGRC - 1 month ago 9
Less Question

How to compile LESS into CSS when files are saved in Eclipse

I'm developing a

struts2 webapp
for months now using maven to manage my dependencies and I've just discovered
LESS
. I have installed and configured the
LESS plug-in for Eclipse
but it's really annoying to
right click > run as > LESS compiler
every time I save the .less file due to a modification of its content or something...

The thing is that I've been researching on how to plug in
grunt.js
(recently discovered task runners too) into maven (as explained here) but I think it's quite hard and I wondered if somebody knew an alternative to this.

In my
struts2
project I have both the front and back-end of my webapp.I know it's not the right approach and if I could start all over again I would separate them into two different projects, but now it's too late (disadvantages of the learning proccess, we're not born knowing it all).

Having said all this, how can I set up a kind of task for watching my
.less
files and automatically compile them into
.css
when saved/changed?

I also found this ant task here, but I dont really know if it's what I'm looking for.

Answer

There are a lot of Java Less compiler (see Java Compiler for Less CSS?), so you can execute one of them by your build tool (e.g. Ant - maybe you need to write a simple Java application, which use the chosen compiler).

If you use Maven (or can switch to it) to project management, then you can use one of lesscss-maven-plugin:

Comments