2016-08-22 58 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