Adding Local JAR to Maven

13 September 2014

Oracle JDBC is not available from Maven's online repository therefore you have to download it from the Oracle website and add the JAR to your local Maven repository. I will not detail how and where to download it but the last time I checked it, it requires login to Oracle website.

After downloading the JAR, you have to open your console and issue mvn install:install-file. Please refer below for the complete syntax. -Dfile requires fullpath.

mvn install

$ mvn install:install-file -Dfile=ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing /home/drmanalo/java/ojdbc6.jar to /home/drmanalo/.m2/repository/com/oracle/ojdb6/11.2.0/ojdb6-11.2.0.jar
[INFO] Installing /tmp/mvninstall6607716975508685322.pom to /home/drmanalo/.m2/repository/com/oracle/ojdb6/11.2.0/ojdb6-11.2.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.687 s
[INFO] Finished at: 2014-09-09T15:11:54+01:00
[INFO] Final Memory: 5M/106M
[INFO] ------------------------------------------------------------------------

pom.xml

Within your POM's dependencies, you need to add the dependency after mvn install.

<dependency>
	<groupId>com.oracle</groupId>
	<artifactId>ojdbc6</artifactId>
	<version>11.2.0</version>
<dependency>

If you have a remote build server, you have to do the mvn install bit to add the dependency knowing you are using different maven local repository. There is another solution posted on this blog but I haven't tried this approach. I'm referring to Installing the jar by using install-plugin. Perhaps this is the way to go but for the time being I'm happy with maven install:install-file.