There are still many Java libraries are not support Maven “POM.xml”, and may be we created a custom library which we want include it into Maven local repository. Maven did provides command to let user include our own or “non-maven-support” library into local repository.

 

For example, “kaptcha” is a third party library which can generate captcha image easily, but it did not support or provide pom.xml for Maven project. Here i demonstrate how to install “kaptcha” jar into my Maven’s local repository.

 

Steps of install custom library in Maven’s local repository

 

1) Download the “kaptcha” jar file and put it into c drive, and issue following command

 

mvn install:install-file -Dfile=c:\kaptcha-2.3.jar -DgroupId=com.google.code
-DartifactId=kaptcha -Dversion=2.3 -Dpackaging=jar

 

Result

 

D:\>mvn install:install-file -Dfile=c:\kaptcha-2.3.jar -DgroupId=com.google.code
-DartifactId=kaptcha -Dversion=2.3 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [install:install-file] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [install:install-file]
[INFO] Installing c:\kaptcha-2.3.jar to D:\maven_repo\com\google\code\kaptcha\2.3\kaptcha-2.3.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Tue May 12 13:41:42 SGT 2009
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------

 

2) Create or modify the Pom.xml file, add the following code

 

<dependency>
      <groupId>com.google.code</groupId>
      <artifactId>kaptcha</artifactId>
      <version>2.3</version>
</dependency>

 

3) Done, “kaptcha” is installed in my Maven local repository.

 

P.S Just issue “mvn eclipse:eclipse” to update our eclipse IDE for the kaptcha library classpath.