1

出于某种原因,我无法theme.less(从 Bootstrap 3.2.0)使用 wro4j 构建/编译。我在 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文件中的某些引用相对应。

错误属性

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构建就好了——只是主题似乎没有。

4

1 回答 1

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>
于 2014-09-11T12:42:17.560 回答