5

I am trying to setup my developer env so that I can use maven to compile my LESS files for formal builds, but also have Eclipse compile the LESS for incremental builds so I dont have to keep kicking of maven tasks every time I make a LESS change. Having looked around - it seems like wro4j & the maven plugin & the m2e-wtp plugin should provide all that.

My setup is as follows: I have just installed the latest stable Eclipse (Java EE package, that includes the WTP stuff - v4.3) and I have installed the m2e plugin and the m2e-wtp plugins.

pom.xml:

<plugin>
    <groupId>ro.isdc.wro4j</groupId>
    <artifactId>wro4j-maven-plugin</artifactId>
    <version>1.4.5</version>
    <executions>
        <execution>
            <phase>compile</phase>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <targetGroups>roa-all</targetGroups>
        <destinationFolder>${project.build.directory}/${project.build.finalName}</destinationFolder>
        <cssDestinationFolder>${project.build.directory}/${project.build.finalName}/css/</cssDestinationFolder>
        <jsDestinationFolder>${project.build.directory}/${project.build.finalName}/js/</jsDestinationFolder>
        <wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
    </configuration>
</plugin>

wro.properties:

preProcessors=cssImport,semicolonAppender   
postProcessors=lessCss,cssMinJawr

wro.xml:

<groups xmlns="http://www.isdc.ro/wro"> 
  <group name="roa-all">
        <css>/less/*.less</css>
    </group>      
</groups>

Inside my /less/ folder are basically a few css files that I have renamed .less files, and one where I have actually added some LESS syntax with a few colour variables set. This mostly works, as I make changes to my LESS, the plugin detects and rebuilds my uber css file, however, rather critically, it doesn't seem to be compiling the LESS - it combines the files, and minifies, but my @variables are all still in LESS syntax.

I also noticed that the maven plugin was up to v 1.7.0 so tried upgrading to that to see if that was the problem, but that just does nothing at all (nothing gets built at all and I have no uber css etc)

Anyone had any experience setting this up or know anything I have missed in the setup?

Mike Braun
  • 3,729
  • 17
  • 15
rhinds
  • 9,976
  • 13
  • 68
  • 111
  • The v1.7.0 should work, what exactly happens when you run maven plugin from console? There is an example project which can be used as a quick start project and can be forked to prove a bug: https://github.com/wro4j/wro4j-examples/tree/master/wro4j-standalone. Also, I recommend using less4j processor instead of lessCss, since it much faster. – Alex Objelean Sep 12 '13 at 20:47
  • Thanks @AlexObjelean - If I run maven from the console it correctly builds and compiles the less files to CSS now I am using 1.7.0, but the eclipse incremental build is still not working with this version (like i mentioned, using 1.4.5 the eclipse build was running, it just didn't compile the LESS) – rhinds Sep 13 '13 at 20:01
  • What maven version are you using? The incremental build feature is supported only by maven 3 or greater. Have you tried the v1.6.3? What happens? You can open an issue and we can continue discussing there, since SO should not be an issue tracker. – Alex Objelean Sep 15 '13 at 07:14
  • I'm noticing this behaviour too. I'm using maven 3. I get an eclipse incremental build if I modify my pom.xml, but if I change a less file nothing happens. – anger Feb 11 '14 at 10:47
  • I never made the full switch to 1.7 or above, but the earlier version is now working ok for me - on the earlier version I was having problems with LESS not being compiled but failing silently - running a full maven build from command line gave more verbose details of issues i saw. I have written up exactly what I had to do (code on github) on my blog here: http://automateddeveloper.blogspot.co.uk/2014/02/eclipse-less-better-development-time.html – rhinds Feb 11 '14 at 14:50
  • @rhinds could you also add a summary as an answer to this question (and accept that?) – Bass Jobsen Oct 11 '14 at 23:12

1 Answers1

1

The problem was because I had some invalid LESS in one of my files - this basically meant the compile step was failing, so the other LESS files were not being compiled to CSS (which resulted in the LESS variables being output in my file) - With the Eclipse incremental build, this failure was not being reported so I didn't see it.

I discovered it by explicitly running the maven command, and then got the normal maven logs which included details of the compilation failure.

That aside, the eclipse incremental build for LESS is working really nicely since!

As mentioned in the comments above, I wrote up how to set it all up here:

Eclipse & LESS - Better development time with incremental builds

rhinds
  • 9,976
  • 13
  • 68
  • 111