Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: how to copy artifact to specific directory?

Tags:

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

like image 983
Mr.Eddart Avatar asked Aug 15 '11 09:08

Mr.Eddart


People also ask

Which command can be used to copy an external artifact from filesystem to local repository?

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

Which Maven phase copy a project artifact in the local repository for use as a dependency?

The dependency:copy goal can also be used to copy the just built artifact to a custom location if desired. It must be bound to any phase after the package phase so that the artifact exists in the repository.

What is Maven clean plugin?

The Maven Clean Plugin, as the name implies, attempts to clean the files and directories generated by Maven during its build. While there are plugins that generate additional files, the Clean Plugin assumes that these files are generated inside the target directory.


1 Answers

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.

like image 195
Petr Kozelka Avatar answered Sep 21 '22 16:09

Petr Kozelka