基于Maven配置文件的web.xml配置 [英] web.xml configuration based on Maven profile
问题描述
可以使用maven插件来让 appengine-web.xml
应用程序基于maven profile运行生成,例如 -Pdev
或 -Pprod
What maven plugin can be used to have the appengine-web.xml
application generated based on the maven profile run, for example -Pdev
or -Pprod
示例:
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>myapp-dev</application>
<version>1</version>
<static-files/>
<threadsafe>true</threadsafe>
<precompilation-enabled>false</precompilation-enabled>
</appengine-web-app>
对于 -Pdev
,以及profile是 -Pprod
For a -Pdev
, and when the profile is -Pprod
应用程序名称应该是:< application> myapp- prod< / application>
The application name would be: <application>myapp-prod</application>
推荐答案
我使用 Maven Replacer插件并用它替换我的appengine-web中的给定字符串 -VERSION - .XML。通过这种方式,我可以在Jenkins上使用多个设置(使用推送进行部署)在不同版本上使用相同的代码进行部署。
I use the Maven Replacer plugin and use it to replace a given String -VERSION- in my appengine-web.xml. This way I get multiple settings on Jenkins (using push to deploy) to deploy on different versions with the same code.
这不是很花哨,但可以完成工作。
It's not really fancy but gets the job done.
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/appengine-web.xml</file>
<token>-VERSION-</token>
<value>${app_version}</value>
</configuration>
</plugin>
这篇关于基于Maven配置文件的web.xml配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!