2

I'm using IntelliJ + Maven to generate war files.

The war is always generated in ProjectDirectory/target/projectname-version.war

After the build process is done, I want to copy the generated war file into a different location (something like cp output X:/remote/tomcat_webapps/projectname.war).

I already tried to configure the directory where maven builds the project (within the pom.xml). However, maven always deletes the containing folder and all its contents, so that is not an option.

How can I automatically copy the generated war file into a different location?

1

1 Answer 1

5

you can modify the maven war plugin in your pom.xml

<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>

I'm not quite sure, if it is the outputDirectory or should it be webappDirectory, like in the documentation

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

1
  • Thank you, that works. Would it be also possible to activate this configuration only for a specific profile? (To have one profile that makes a local build, and another one that deploys it on the server)
    – maja
    Aug 9, 2015 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.