Thursday, January 28, 2016

force maven to add jars to your workspace (eclipse)

Firs of all, the reason why I am posting this is: I hit a snag because of this and took a few hours to resolve my issue. The following plugin came to rescue, so I though to post it in case anybody else in the world needs it.

Just adding the execution plugin in your pom.xml does the trick of downloading all the jars to the target directory of your project in eclipse. 

<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>

Here is how the same would look like under the parent build element. 

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

If this is what you were looking for, hope it is a help!

Cheers!