Maven: how to copy artifact to specific directory?

Mr.Eddart picture Mr.Eddart · Aug 15, 2011 · Viewed 40.7k times · Source

The "install" goal copies the artifact to the target directory and to the local repository.

How can I tell Maven to copy it also to a given directory (like the deploy directory of JBoss for example).

Answer

Petr Kozelka picture Petr Kozelka · Aug 15, 2011

The goal copy of maven-dependency-plugin does what you want, see the example.

It is however not a good idea to copy anything outside your target directory (or ${project.build.directory} to be precise) - especially if such action is attached to a build phase, because it introduces unexpected side-effects of the build, and sometimes even loss of reproducibility.

As @Andreas_D notes, there is a better alternative for JBoss deployment purpose; similarly for deploying to other appservers.