使用Twitter Bootstrap的theme.less与wro4j-maven-plugin

时间:2014-09-10 03:23:47

标签: twitter-bootstrap maven wro4j

出于某种原因,我无法通过wro4j获取theme.less(来自Bootstrap 3.2.0)来构建/编译。我在Maven插件输出中遇到了一些错误,例如:

[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).

由于CSS导入,行号无用,但它们看起来与theme.less文件中的某些引用相对应。

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>

我担心我在这里出于想法。正常bootstrap.less构建得很好 - 它只是似乎没有的主题。

1 个答案:

答案 0 :(得分:1)

这是less4j中的一个错误,维护者非常善意地修复了这个错误。更新到新的less4j 1.8.2版本解决了这个问题:

<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>