Monday, December 5, 2011

Manually install a maven dependency

execute the following command from the command line with the correct values for options. -Dfile option locates the downloaded jar file. Therefore make sure to specify the correct location or reach the jar location from the command line and execute the command.


mvn install:install-file -DgroupId=ojdbc -DartifactId=ojdbc6 \
     -Dversion=10.2.0.3.0 -Dpackaging=jar -Dfile=ojdbc6.jar -DgeneratePom=true

How to add Maven dependency from a relative path referencing a local jar

When you want to add a dependency which is not stored in maven repositories to your project this is the way!! You can manually download it and include inside the project and refer it from the pom.xml through a relative path.

This example assumes that you have downloaded and stored the jar inside ${project}/src/test/resources/lib. 
       
                ojdbc
                ojdbc6
                system
                6
                ${basedir}/src/test/resources/lib/ojdbc6.jar
        
Here we must specify the scope of the dependency  as 'system'. There is another way which is to manually install the maven dependency to your local repository. You can find out how from here.