2012-11-13 40 views
2

我試圖讓wro4j Maven插件工作,不幸的是我被帶有一個錯誤,我不太明白它的原因:Wro4j Maven插件:無效wro.xml

[ERROR] Failed to execute goal ro.isdc.wro4j:wro4j-maven-plugin:1.5.0:run (proprocess- resources) on project someapp-webapp: Exception occured while processing: startup failed: 
[ERROR] Script1.groovy: 1: unexpected token: < @ line 1, column 1. 
[ERROR] <groups xmlns="http://www.isdc.ro/wro" 

這裏是我的配置:

的pom.xml:

<plugin> 
    <groupId>ro.isdc.wro4j</groupId> 
    <artifactId>wro4j-maven-plugin</artifactId> 

    <executions> 
     <execution> 
      <id>proprocess-resources</id> 
      <phase>compile</phase> 
      <goals> 
       <goal>run</goal> 
      </goals> 
     </execution> 
    </executions> 

    <configuration> 
     <targetGroups>all</targetGroups> 
     <wroFile>src/build/wro.xml</wroFile> 
     <destinationFolder>${project.build.directory}/dist</destinationFolder> 
     <contextFolder>${basedir}/src/main/webapp/</contextFolder> 
     <extraConfigFile>src/build/wro.properties</extraConfigFile> 
    </configuration> 

</plugin> 

這是我的wro.xml文件:

<groups xmlns="http://www.isdc.ro/wro" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://www.isdc.ro/wro wro.xsd"> 

    <group name="all"> 
    <js>/src/main/webapp/js</js> 
    <css>/src/main/webapp/css</css> 
    </group> 

</groups> 

另外我有一個wro.properties文件:

debug=true 
gzipResources=false 
ignoreMissingResources=true 
jmxEnabled=true 
managerFactoryClassName=ro.isdc.wro.examples.manager.CustomWroManager 
preProcessors=sassCss 

我沒有看到的東西,我可以在wro4j文檔中已經錯過了,您的任何建議,我將不勝感激!

+0

我從網頁上取得了樣本XML。上述沒有幫助,但似乎Wro4j使用GroovyModelFactory作爲默認值。該網頁並沒有指出這一點......改變groovy有助於。 http://code.google.com/p/wro4j/wiki/GroovyWroModel –

+0

只有在分析xml DSL失敗時纔會使用groovyModelFactory。查看示例模塊中的工作示例。 –

回答

3

默認情況下,wro4j使用SmartWroModelFactory,它會依次嘗試使用所有可用的DSL構建模型:xml,groovy,json。您的失敗表明xml模型無法創建,因此它試圖將其創建爲一個常規DSL。由於提供的xml模型似乎是有效的,所以你失敗的唯一原因是xml位置不是有效的。

或許你可以嘗試更換:

<wroFile>src/build/wro.xml</wroFile><wroFile>/src/build/wro.xml</wroFile>

1

我發現我不得不刪除XML文件,而不是對1.6.2 wro4j創建wro.groovy文件。

groups { 
    group1 { 
    js("/app/**.js") 
    css("/resources/css/*.css") 
    } 
    all { 
    group1() 
    } 
}