maven-war-pluginを使用してmaven経由でweb.xmldisplay-nameを定義するにはどうすればよいですか?
maven-ear-pluginには、EAR /application.xmldisplay-name属性を設定するための構成オプションdisplayNameがあります。
間違ったアプローチ?web.xmlで手動で設定するだけですか?
maven-war-pluginを使用してmaven経由でweb.xmldisplay-nameを定義するにはどうすればよいですか?
maven-ear-pluginには、EAR /application.xmldisplay-name属性を設定するための構成オプションdisplayNameがあります。
間違ったアプローチ?web.xmlで手動で設定するだけですか?
MavenのWebリソースフィルタリングアプローチを使用する必要があります。maven-war-pluginで次の構成を設定します。
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp/WEB-INF/</directory>
<targetPath>WEB-INF</targetPath>
<includes><include>web.xml</include></includes>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
また、web.xmlでは、pom.xmlで定義されている任意のプロパティを使用できます。したがって、たとえば、次を使用できます。
<display-name>${project.name} - ${project.version}</display-name>
それは次のようにレンダリングされます
<display-name>My Awesome Webapp - 1.0.0-SNAPSHOT</display-name>
Eclipseを使用する場合は、m2e-wtpが必要です(ホームページのWebリソースフィルタリングスクリーンキャストを参照してください)
はるかに単純です...
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
</configuration>
</plugin>
FilteringDeploymentDescriptorsのドキュメントを参照してください。これは2.1以降で使用可能ですが、デフォルトでは無効になっています。