How to install and use the latest library when it is not available in Maven repository
Maven tool is great but the first time I use it, I have had some difficulties of managing dependencies in my project. I use hibernate 3.2 as the ORM framework in my project, but I only found hibernate 3.1beta as the latest version in Maven repository folder. More badly if I use Maven Eclipse plug-in the hibernate versions are available even more older.
That is my problem, I already have hibernate 3.2 on my machine but it is likely I must use the older version by downloading on remoting server (the bad news is that hibernate annotation tool uses java persistence api that can not be downloaded, that means I can not use hibernate annotations in my project!). I would like to use the latest library but unfortunately it is not available in Maven repository. That makes I need to create such one on my local repository. I have done two steps to solve that problem:
- Open the console and tell Maven install the library: mvn install:install-file -Dfile='path of library' -DgroupId='group id of library' -DartifactId='artifact id of library' -Dversion='version' -Dpackaging=jarMore specific example in case I installed hibernate library mvn install:install-file -Dfile=lib/hibernate/hibernate-annotations.jar -DgroupId=hibernate -DartifactId=hibernate-annotations -Dversion=3.2 -Dpackaging=jarMaven has installed your library to local repository. Check it in your local repository folder, in my case I checked at %MY_HOME_DIR%\.m2\repository\${group.id}\${artifact.id}\${version}(c:\Documents and Settings\hpnguyen\.m2\repository\hibernate\hibernate-annotations\3.2\)
- You need to create a pom file for your library. Open your local repository and create the corresponding pom file for your library. In my case, I created pom file name hibernate-annotations-3.2.pom and located it in %MY_HOME_DIR%\.m2\repository\hibernate\hibernate-annotations\3.2\, the content if pom file is here
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.2</version>
<dependencies>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>ejb</artifactId>
<version>3.0-public_review</version>
</dependency>
</dependencies>
</project>
After finish this two step, you can use your latest library that is not listed in Maven repository.