IntelliJ:构建后复制war文件

maj*_*aja 2 intellij-idea maven

我正在使用IntelliJ + Maven生成war文件.

战争总是产生于 ProjectDirectory/target/projectname-version.war

构建过程完成后,我想将生成的war文件复制到不同的位置(类似cp output X:/remote/tomcat_webapps/projectname.war).

我已经尝试配置maven构建项目的目录(在pom.xml中).但是,maven总是删除包含文件夹及其所有内容,因此这不是一个选项.

如何自动将生成的war文件复制到其他位置?

dan*_*iel 5

你可以修改pom.xml中的maven war插件

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.6</version>
      <configuration>
        <outputDirectory>X:/remote/tomcat_webapps</outputDirectory>
      </configuration>
    </plugin>
  </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

我不太确定,如果它是outputDirectory,或者它应该是webappDirectory,就像在文档中一样

https://maven.apache.org/plugins/maven-war-plugin/usage.html