Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Maven to copy dependencies into target/lib

How do I get my project's runtime dependencies copied into the target/lib folder?

As it is right now, after mvn clean install the target folder contains only my project's jar, but none of the runtime dependencies.

like image 527
Michael Avatar asked Sep 18 '08 22:09

Michael


People also ask

How do I force Maven to download dependencies from remote repository?

Force maven to fetch dependencies from the remote repository while building the project. We can use -U/--update-snapshots flag when building a maven project to force maven to download dependencies from the remote 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.


2 Answers

This works for me:

<project>   ...   <profiles>     <profile>       <id>qa</id>       <build>         <plugins>           <plugin>             <artifactId>maven-dependency-plugin</artifactId>             <executions>               <execution>                 <phase>install</phase>                 <goals>                   <goal>copy-dependencies</goal>                 </goals>                 <configuration>                   <outputDirectory>${project.build.directory}/lib</outputDirectory>                 </configuration>               </execution>             </executions>           </plugin>         </plugins>       </build>     </profile>   </profiles> </project> 
like image 82
Georgy Bolyuba Avatar answered Sep 18 '22 06:09

Georgy Bolyuba


mvn install dependency:copy-dependencies  

Works for me with dependencies directory created in target folder. Like it!

like image 45
user3286149 Avatar answered Sep 19 '22 06:09

user3286149