我不知道這是否符合你的問題,但我想填充生成過程中從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 = "<display-name>[^<]*</display-name>";
def replace = "<display-name>"+project.description+" "+project.version+"</display-name>";
fileText = fileText.replaceAll(match, replace);
file.write(fileText);
println "Updated web.xml"
</source>
</configuration>
</execution>
</executions>
</plugin>
這是一個小黑客,謝謝! – 2012-04-24 23:34:02
xml作爲文本而不是dom處理是一種完全的破解,我同意。 – Julian 2012-04-25 18:57:30
感謝您接受這一點,雖然我有點驚訝 - 我閱讀了資源過濾及其更高級別和潛在有趣的事情比我的小黑客,這做我所需要的,但顯然不是你所需要的。 – Julian 2012-05-02 06:12:07