how to get all dependent JARS in Maven easily?

Hello everyone,

I am working on a Maven project using IntelliJ. There are many dependencis defined in pom.xml, and wondering if any easy way to get all the JARS (the reason why I want to get the JARs, is because during Java program runtime, I need to set the JARs into classpath)? Currently, I have to find and copy them one by one from Maven repository. If any tricks which could dump all JARs into one directory, it will be great.

thanks in advance,
Lin

4 comments
Comment actions Permalink
 
<build>
   <plugins>
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
         <version>2.5</version>
         <executions>
            <execution>
               <id>copy-dependencies</id>
               <phase>package</phase>
               <goals>
                  <goal>copy-dependencies</goal>
               </goals>
               <configuration>
                  <outputDirectory>${project.basedir}/../lib/</outputDirectory>
                  <overWriteReleases>false</overWriteReleases>
                  <overWriteSnapshots>false</overWriteSnapshots>
                  <overWriteIfNewer>true</overWriteIfNewer>
                  <useSubDirectoryPerScope>true</useSubDirectoryPerScope>
               </configuration>
            </execution>
            <execution>
               <id>copy-sources</id>
               <phase>package</phase>
               <goals>
                  <goal>copy-dependencies</goal>
               </goals>
               <configuration>
                  <outputDirectory>${project.basedir}/../lib/source</outputDirectory>
                  <overWriteReleases>false</overWriteReleases>
                  <overWriteSnapshots>false</overWriteSnapshots>
                  <overWriteIfNewer>true</overWriteIfNewer>
                  <useSubDirectoryPerScope>true</useSubDirectoryPerScope>
                  <classifier>sources</classifier>
               </configuration>
            </execution>

         </executions>

      </plugin>
   </plugins>
</build>
0
Comment actions Permalink

Thanks Vojtěch Krása,

Wondering what is the value for "${project.basedir}", is it the directory where pom.xml is located? Thanks.

regards,
Lin

0
Comment actions Permalink

Hi Vojtěch Krása,

Any comments to my above question is appreciated. Thanks.

regards,
Lin

0
Comment actions Permalink

umm, it probably is, just try it

0

Please sign in to leave a comment.