Maven copy artifact to different directory than the local repository

The maven-jar-plugin creates the artifacts jar into ${project.build.directory} (by default target/). The maven-install-plugin copies this file to the local Maven repository (by default %user.home%/.m2/repository).

Sometimes it is wanted to additionally copy this artifact into another location. For example to deploy the artifact to a server. Two possibilities come to my mind to solve this problem:

For example, one could copy all *.jar files in the target directory like this:

<plugin>
  <groupId>com.github.goldin</groupId>
  <artifactId>copy-maven-plugin</artifactId>
  <version>0.2.5</version>
  <executions>
    <execution>
      <id>deploy-to-local-directory</id>
      <phase>install</phase>
      <goals>
        <goal>copy</goal>
      </goals>
      <configuration>
        <skipIdentical>false</skipIdentical>
        <failIfNotFound>false</failIfNotFound>
        <resources>
          <resource>
            <description>Copy artifact to another directory</description>
            <targetPath>your/local/path</targetPath>
            <directory>${project.build.directory}</directory>
            <includes>
              <include>*.jar</include>
            </includes>
          </resource>
        </resources>
      </configuration>
    </execution>
  </executions>
</plugin>

Suggested from me at stackoverflow.