2016-08-22 48 views
0

我的web.xml不在${project.root}\src\main\webapp\WEB-INF使用Google Maven替换器替换WAR文件中的web.xml中的令牌

我想使用com.google.code.maven-replacer-plugin来替换它内部的一些标记,当它被打包在WAR中但不在源目录中时,它将被替换为

我想:

<plugin> 
    <groupId>com.google.code.maven-replacer-plugin</groupId> 
    <artifactId>replacer</artifactId> 
    <version>1.5.2</version> 
    <executions> 
    <execution> 
     <phase>prepare-package</phase> 
     <goals> 
     <goal>replace</goal> 
     </goals> 
    </execution> 
    </executions> 
    <configuration> 
    <file>src/main/webapp/WEB-INF/web.xml</file> 
    <replacements> 
     <replacement> 
     <token>@@[email protected]@</token> 
     <value>local</value> 
     </replacement> 
    </replacements> 
    </configuration> 
</plugin> 

但我得到

[ERROR] File '.\src\main\webapp\WEB-INF\web.xml' does not exist 

由于这个文件是不是target文件结构下的复制,是刚刚从源头上采取直接进入WAR(或因此我想想),我如何在上面的configuration->file参数中引用它的路径,以便替换者找到它并替换这些标记?

回答

1

尝试如下不同的变量maven properties

然而
+0

${project.basedir}/src/main/webapp/WEB-INF/web.xml 

更多信息,更改文件源使用的路径,我想离开源不变(保持令牌),只在构建中更改它,WAR文件 – amphibient

+0

您尝试过使用$ {project.build.directory},但您需要提供适当的阶段(因为在创建war文件之前必须完成该阶段) – ravthiru