2012-04-22 28 views
2

我需要在這個問題上得到一些更新,我發現this thread back in 2009 here,但答案是使用maven 2,我不確定Q4E是否適用於maven 3。我需要在mvn包階段過濾一些屬性文件,以使結果戰爭正常運行,通過CLI mvn install,資源篩選工作正常。但是,當我做「運行在服務器上的服務器/調試」,過濾不再工作。 上述線程作者最終使用q4e,聲稱q4e獲得​​資源過濾權。我同時安裝了q4e以及m2e,但仍然不起作用,所以我不知道q4e是否與maven 3一起工作,或者我做錯了什麼。 謝謝,當我需要資源過濾屬性文件時,如何在Eclipse中運行Maven Web應用程序?

大衛

回答

1

(自0.12資源過濾bug修復)更新到最新的M2E-WTP插件0.15,現在工作得很好。

0

我不知道這是否符合你的問題,但我想填充生成過程中從POM性能我的web.xml文件,然後我把Groovy腳本在POM以做到這一點。它工作的一種享受,也可能爲你工作。它肯定在eclipse和命令行中均可用。這裏是我的POM片段:

<plugin> 
<!-- Groovy script to set the description and version in the web.xml display name --> 
    <groupId>org.codehaus.groovy.maven</groupId> 
    <artifactId>gmaven-plugin</artifactId> 
    <version>1.0</version> 
    <executions> 
     <execution> 
     <id>groovy-magic</id> 
     <phase>prepare-package</phase> 
     <goals> 
      <goal>execute</goal> 
     </goals> 
     <configuration> 
      <source> 
      def file = new File("src/main/webapp/WEB-INF/web.xml"); 
      def fileText = file.text; 
      def match = "&lt;display-name>[^&lt;]*&lt;/display-name>"; 
      def replace = "&lt;display-name>"+project.description+" "+project.version+"&lt;/display-name>"; 
      fileText = fileText.replaceAll(match, replace); 
      file.write(fileText); 
      println "Updated web.xml" 
      </source> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 
+0

這是一個小黑客,謝謝! – 2012-04-24 23:34:02

+0

xml作爲文本而不是dom處理是一種完全的破解,我同意。 – Julian 2012-04-25 18:57:30

+0

感謝您接受這一點,雖然我有點驚訝 - 我閱讀了資源過濾及其更高級別和潛在有趣的事情比我的小黑客,這做我所需要的,但顯然不是你所需要的。 – Julian 2012-05-02 06:12:07

相關問題