Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wro4j & m2e Eclipse not compiling LESS

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?

like image 387
rhinds Avatar asked Nov 12 '22 22:11

rhinds


1 Answers

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

like image 170
rhinds Avatar answered Nov 15 '22 06:11

rhinds