1

For some reason, I can't get theme.less (from Bootstrap 3.2.0) to build/compile with wro4j. I get a number of errors in the Maven plugin output, such as:

[INFO] processing group: bootstrap-theme.css
2487 ERROR Less4jProcessor      - Failed to compile less resource: ro.isdc.wro.model.resource.Resource@53bb87b9[CSS,bootstrap-theme,true].
2487 ERROR Less4jProcessor      - 2069:13 no viable alternative at input '>' in ruleset (which started at 2068:1).
2487 ERROR Less4jProcessor      - 2069:25 mismatched input '@start-color' expecting '~'<escaped value>'' in selectors (which started at 2069:3).
2487 ERROR Less4jProcessor      - 2069:25 no viable alternative at input '@start-color' in ruleset (which started at 2069:3).
2487 ERROR Less4jProcessor      - 2069:46 no viable alternative at input '@progress-bg' in selectors (which started at 2069:37).

The line numbers are useless due to the CSS imports, but they look to correspond to some of the references in the theme.less file.

wro.properties

preProcessors=cssImport,semicolonAppender   
postProcessors=less4j,cssMinJawr

wro.xml

<groups xmlns="http://www.isdc.ro/wro">
    <!-- This file configures the Web Resource Optimizer for Java (wro4j). This 
        tool minifies JS, compiles LESS CSS, etc. See https://code.google.com/p/wro4j/ 
        and https://github.com/jbosstools/m2e-wro4j/wiki/Sample-twitter-bootstrap-project 
        for details. -->
    <group name="bootstrap">
        <css>/bootstrap-3.2.0/less/bootstrap.less</css>
        <js>/bootstrap-3.2.0/js/*.js</js>
    </group>
    <group name="bootstrap-theme">
        <css>/bootstrap-3.2.0/less/theme.less</css>
    </group>
</groups>

pom.xml

<plugin>
    <!-- Run the Web Resource Optimizer for Java (wro4j) as part of the build. 
        This tool minifies JS, compiles LESS CSS, etc. See https://code.google.com/p/wro4j/ 
        and https://github.com/jbosstools/m2e-wro4j/wiki/Sample-twitter-bootstrap-project 
        for details. -->
    <groupId>ro.isdc.wro4j</groupId>
    <artifactId>wro4j-maven-plugin</artifactId>
    <version>1.7.6</version>
    <configuration>
        <wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
        <!-- <targetGroups>bootstrap</targetGroups> -->
        <!-- Search for resources in both the source and output trees, to ensure 
            that generated resources are also found. -->
        <contextFolder>${basedir}/src/main/webapp/,${project.build.directory}</contextFolder>
        <destinationFolder>${project.build.outputDirectory}/${project.build.finalName}</destinationFolder>
        <cssDestinationFolder>${project.build.directory}/${project.build.finalName}/WEB-INF/resources/css</cssDestinationFolder>
        <jsDestinationFolder>${project.build.directory}/${project.build.finalName}/WEB-INF/resources/js</jsDestinationFolder>
    </configuration>
    <executions>
        <execution>
            <phase>compile</phase>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>

I'm afraid that I'm rather out of ideas here. The normal bootstrap.less builds just fine-- it's only the theme that seem to not.

Karl M. Davis
  • 606
  • 1
  • 7
  • 22
  • 1
    The wro4j-1.7.6 uses older version of less4j. Try adding explicitly a dependency to latest less4j version: 1.8.1. If that doesn't work, try to isolate the problem and report it either on wro4j or on less4j (submit an issue). – Alex Objelean Sep 10 '14 at 06:52
  • 2
    @AlexObjelean: Bumping the less4j version did not fix the problem. Based on some further investigation (and guessing) I went ahead and opened it as a less4j issue: https://github.com/SomMeri/less4j/issues/228 – Karl M. Davis Sep 10 '14 at 14:02

1 Answers1

1

This was a bug in less4j, which the maintainer has very kindly fixed. Updating to the new less4j 1.8.2 release resolves the issue:

<plugin>
    <!-- Run the Web Resource Optimizer for Java (wro4j) as part of the build. 
        This tool minifies JS, compiles LESS CSS, etc. See https://code.google.com/p/wro4j/ 
        and https://github.com/jbosstools/m2e-wro4j/wiki/Sample-twitter-bootstrap-project 
        for details. -->
    <groupId>ro.isdc.wro4j</groupId>
    <artifactId>wro4j-maven-plugin</artifactId>
    <version>1.7.6</version>
    <configuration>
        <wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
        <!-- <targetGroups>bootstrap</targetGroups> -->
        <!-- Search for resources in both the source and output trees, to ensure 
            that generated resources are also found. -->
        <contextFolder>${basedir}/src/main/webapp/,${project.build.directory}</contextFolder>
        <destinationFolder>${project.build.outputDirectory}/${project.build.finalName}</destinationFolder>
        <cssDestinationFolder>${project.build.directory}/${project.build.finalName}/WEB-INF/resources/css</cssDestinationFolder>
        <jsDestinationFolder>${project.build.directory}/${project.build.finalName}/WEB-INF/resources/js</jsDestinationFolder>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>com.github.sommeri</groupId>
            <artifactId>less4j</artifactId>
            <version>1.8.2</version>
        </dependency>
    </dependencies>
    <executions>
        <execution>
            <phase>compile</phase>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Karl M. Davis
  • 606
  • 1
  • 7
  • 22