2

Editing the original question to provide all the details.

Added following in web.xml:

<filter>
    <filter-name>WroContextFilter</filter-name>
    <filter-class>ro.isdc.wro.http.WroContextFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>WroContextFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<filter>
    <filter-name>WebResourceOptimizer</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    <init-param>
        <param-name>targetBeanName</param-name>
        <param-value>wroFilter</param-value>
    </init-param>
    <init-param>
        <param-name>targetFilterLifecycle</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>WebResourceOptimizer</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

Created two new files wro.xml and wro.properties inside WEB-INF folder:

wro.properties:

managerFactoryClassName=ro.isdc.wro.manager.factory.ConfigurableWroManagerFactory
preProcessors=less4j,cssUrlRewriting,lessCssImport
postProcessors=less4j
disableCache=true

wro.xml:

<groups xmlns="http://www.isdc.ro/wro">
    <group name="base">
        <css>/resources/skins/abc/testing.less</css>
    </group>
</groups>

Here 'resources' is a folder inside: src/main/webapp.

A file testing.less is added inside /resources/skins/abc/ folder:

.btn-expand (@height: 30px) {
        box-sizing: border-box;
        height: @height;
        display: inline-block;
        color: #fff;
        font-size: 12px;
        text-decoration: none;
        padding-left: 20px;
        padding-right: 1px;
        margin-right: 20px;
        background: transparent url('images/sprites.png') no-repeat -5px -164px;
        border: 0;
        position: relative;
        outline: none;
        cursor:pointer;
        overflow: visible;
    }

The pom.xml file contains the following entries:

<repository>
    <id>releases</id>
    <name>Releases</name>
    <url>https://oss.sonatype.org/content/repositories/releases</url>
</repository>   (Inside <repositories> tag)

<dependency>
    <groupId>ro.isdc.wro4j</groupId>
    <artifactId>wro4j-core</artifactId>
    <version>1.6.2</version>
</dependency>  (Inside <dependencies> tag)

<plugin>
    <groupId>ro.isdc.wro4j</groupId>
    <artifactId>wro4j-maven-plugin</artifactId>
    <version>1.7.3</version>
    <configuration>
    <targetGroups>base</targetGroups>
        <wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
        <cssDestinationFolder>${project.build.directory}/${project.build.finalName}/resources/css/test/</cssDestinationFolder>
        <wroFile>${basedir}/src/main/webapp/WEB-INF/wro.xml</wroFile>
        <extraConfigFile>${basedir}/src/main/webapp/WEB-INF/wro.properties</extraConfigFile>
        <contextFolder>${basedir}/src/main/webapp/</contextFolder>
        <ignoreMissingResources>false</ignoreMissingResources>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>run</goal>
            </goals>
            <phase>prepare-package</phase>
        </execution>
    </executions>
</plugin>  [Inside <build> <plugins> tag.] 

I have not installed the m2e-wro4j plugin in my eclipse IDE.

Based on the above, I assume that when i do a maven build from command prompt [mvn clean install], a css file named base.css should be created inside /resources/css/test/ folder. I can see the new folder 'test' in the exploded project WAR file but it does not contain the base.css file. The console output looks something like this:

[INFO] Wro4j Model path: C:\workspace\{projectname}\src\main\webapp\WEB-INF\wro.xml
[INFO] targetGroups: base
[INFO] minimize: true
[INFO] ignoreMissingResources: false
[INFO] parallelProcessing: false
[INFO] destinationFolder: C:\workspace\{projectname}\target
[INFO] jsDestinationFolder: null
[INFO] cssDestinationFolder: C:\workspace\{projectname}\target\{WAR file name}\resources\css\test
[INFO] groupNameMappingFile: null
[INFO] wroManagerFactory class: ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory
[INFO] The following groups will be processed: [base]
[INFO] folder: C:\workspace\{projectname}\target\{WAR file name}\resources\css\test
[INFO] processing group: base.css
[INFO] folder: C:\workspace\{projectname}\target
[INFO] processing group: base.js 

One more observation. To make sure that that wro.properties file is correctly placed and is picked up by the plugin, I tried some wrong values in this file [postProcessors=less4jtttt] and could see an exception while doing the build. However, an invalid file path in wro.xml file did not throw any exception.

4

1 回答 1

1

虽然答案也发布在邮件列表中,但我也会在这里发布以供查看:

我已经设法在本地重现您的测试用例,我看到的是一个空文件。第一印象是有问题,但实际上这是预期的行为。处理的内容越少,定义了一个 mixin,只要不使用它就不会产生任何输出。

要获得有效的输出,请更新您的 less 以使用该 mixin:

div.expandable {
    .btn-expand()
}  
于 2014-02-04T12:19:29.857 回答