Srcディレクトリのファイルを変更せずに、srcディレクトリの一部のファイルの内容をwarに置き換えることを計画しています。だから私はmaven-replacer-pluginを使用しています
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<!-- the replace should happen before the app is packaged -->
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<!-- replace the token in this file -->
<include>target/**/*.html</include>
</includes>
<regex>false</regex>
<!-- the name of the token to replace -->
<token>BUILD_TIME</token>
<!-- replace it with the maven project version -->
<value>${timestamp}</value>
</configuration>
パッケージの準備段階で、ターゲット ディレクターでファイルが置き換えられているのがわかります。これは、mvn prepare-package を実行するだけで確認でき、BUILD_TIME がビルド時間に置き換えられていることがわかります。ただし、パッケージ フェーズが実行されると、src ディレクトリのコンテンツが置き換えられます。以下のスクリーン ショットから、prepare-package 後の次のフェーズで、問題の原因となっている src ディレクトリから Web アプリ リソースがコピーされていることがわかります。
パッケージ段階でこのプラグインを使用しようとしましたが、これも成功しませんでした (ターゲット ディレクトリの html でビルド時間を確認できますが、war 内では確認できません)。