Welcome, Guest. Please Login or Register
WebLab Project
  You can now retrieve WebLab Core sources from our OW2 SVN
  Warning ! This forum is now locked, new posts have been disabled. If you want to contact us about a problem or have question, please use the following mailing list:
user@weblab-project.org !
  HomeHelpSearchLoginRegister  
 
 
Page Index Toggle Pages: 1
Send Topic Print
[Resolved] Using external JARs with Maven ? (Read 2223 times)
16.06.2008 at 13:34:56

Benjamin Nguyen   Offline
WebLab Newbies
I Love WebLab
University of Versailles

Posts: 12
*
 
Hello,

I'm currently (re)implementing the MonetDB store service, using the maven framework (which we did not initially use). I ran through the tutorial and had no problem, there is just one problem I have now : I use many external jars, where (or how) must I install them in order for them to be found by maven when I run mvn compile or mvn package ? I tried unzipping them into my local repository location but this does not seem to work. Is there something I am missing ?

This is the error received :

Code:
[INFO] Compiling 22 source files to C:\ServiceWebContent\dev\storeMonet\target\classes
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure

C:\ServiceWebContent\dev\storeMonet\src\main\java\service\MonetDBconfig.java:[25,35] package org.apache.xerces.framework does not exist

C:\ServiceWebContent\dev\storeMonet\src\main\java\service\MonetDBconfig.java:[26,35] package org.apache.xerces.framework does not exist

C:\ServiceWebContent\dev\storeMonet\src\main\java\service\MonetDBconfig.java:[27,31] package org.apache.xerces.utils does not exist

etc... 




Thanks,

BN
« Last Edit: 19.06.2008 at 18:53:25 by Yann Mombrun »  
IP Logged
 
Reply #1 - 16.06.2008 at 14:37:59

Yann Mombrun   Offline
WebLab Administrator
I Love WebLab
Val de Reuil, France

Gender: male
Posts: 79
*****
 
Mavenize non-maven project could be long but is an easy task.

First you have to list every dependencies (jar in most of the cases) that your project import, ie. MonetDB and every of it's dependencies.
For each dependency, look if the maven version exists (http://mvnrepository.com is your friend).
If the maven version exists, import-it (in the dependencies section of your pom.xml file.
Else you have to install the jar in your local repository and then importing-it.


To install a third party jar on your repo:
Code:
mvn install:install-file -Dfile=path-to-the-artifact.jar [-DgroupId=org.some.group] [-DartifactId=the-artifact] [-Dversion=version] [-Dpackaging=jar] [-DgeneratePom=true] 

 
IP Logged
 
Reply #2 - 16.06.2008 at 14:59:13

Benjamin Nguyen   Offline
WebLab Newbies
I Love WebLab
University of Versailles

Posts: 12
*
 
ok so I decided to install the 3rd party jars on my local rep : I typed some random information for the groupId and artifactId (for instance I put : groupId : nl.cwi.monetdb and artifactID : monet-jdbc version 1.6

This created the hierarchy on my repository :

C:\ServiceWebContent\repository\nl\cwi\monetdb\monet-jdbc\1.6

where the jar was copied... is this ok ? (I've got quite a few libraries to install so I just want to check I'm doing it right Smiley )

Many thanks,

BN

 
IP Logged
 
Reply #3 - 16.06.2008 at 15:37:41

Gérard Dupont   Offline
WebLab Administrator
WebLab addict.

Posts: 69
*****
 
Actually this is the right way, but you also have to ensure that the libraries that you are installing do not have themselve others dependencies. This is the "maven mess"...

Hopfully someone has done this before you and your librairies are already on a remote repository. Try here :

http://www.mvnrepository.com/
 
IP Logged
 
Reply #4 - 19.06.2008 at 12:16:50

Benjamin Nguyen   Offline
WebLab Newbies
I Love WebLab
University of Versailles

Posts: 12
*
 
I suppose that to download all this automatically I must compile with the option <offline>false</offline> in the settings.xml configuration file, and then it is all automatic (if the libraries have already been added?)

Also : is there not a risk of having duplicate files if I use some more or less random artifact name ?

Thanks

BN
 
IP Logged
 
Reply #5 - 19.06.2008 at 18:52:48

Yann Mombrun   Offline
WebLab Administrator
I Love WebLab
Val de Reuil, France

Gender: male
Posts: 79
*****
 
If the groupId/artifactId of the jar you are deploying do not exist, you will not have any duplicate trouble.
Anyway, if that appear and the version number is not ending with -SNAPSHOT, Maven will not replace your local repository jar version by any existing one on a remote repo with same groupId and artifactId.
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print