Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add jars needed to compile a maven project if they were never built with a pom?

Tags:

maven-2

jar

ant

I'm just starting with maven, coming from years of working with Ant. I'm trying a basic task now, building a simple project that requires some libraries from a vendor. I have the jars in src\main\resources\VENDORNAME. When I run mvn compile it fails on compilation saying the libraries don't exist. I can't seem to add these as dependencies because I don't know their version number and as they are proprietary I can't find them in ibiblio or elsewhere. Without these Jars I can't compile my classes.
Is there a way to use jars that didn't follow Maven's convention? I might not understand maven correctly, so any guidance is welcome. Much appreciated for any responses.

like image 291
JasonH Avatar asked Oct 15 '22 05:10

JasonH


1 Answers

I would write your own POM file for these jars and add them to your repository. Doesn't have to be anything fancy, just a bare-bones POM file. That way you can include them without breaking "The Maven Way".

If you want Maven to automatically generate one for you, and install it to your local repo, you can use this command:

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
    -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
like image 57
dbyrne Avatar answered Oct 20 '22 19:10

dbyrne