Monday, November 19, 2012

Local JARs for Maven Dependency


1. download jar into /mavenlocal

2. run

mvn install:install-file -DgroupId=classifier4j -DartifactId=Classifier4J -Dversion=0.6 -Dpackaging=jar -DcreateChecksum=true -Dfile=/home/xzhao/mavenlocal/Classifier4J-0.6.jar

3. Add dependency


<dependency>
    <groupId>classifier4j</groupId>
    <artifactId>Classifier4J</artifactId>
    <version>0.6</version>
</dependency>

The following method not working well


1. Download jar file into /lib

2. Use Maven to install to project repo

 mvn install:install-file -DlocalRepositoryPath=repo -DcreateChecksum=true -Dpackaging=jar -Dfile=[your-jar] -DgroupId=[...] -DartifactId=[...] -Dversion=[...]  

maven repository created in /lib/repo



3. Add repository in pom.xml

 <repository>  
   <id>repo</id>  
   <url>file://${project.basedir}/repo</url>  
 </repository>  

4. Add dependencies


sources:
  • http://stackoverflow.com/questions/364114/can-i-add-jars-to-maven-2-build-classpath-without-installing-them
  • http://blog.dub.podval.org/2010/01/maven-in-project-repository.html

No comments:

Post a Comment