Adding a jar library to a Maven project

I have a project developed at Maven. I want to add a new jar file in classpath. I added a new dependency to the pom.xml file:

<dependency> <groupId>mzmatch</groupId> <artifactId>mzmatch</artifactId> <version>1.2.13</version> </dependency> 

All jar libraries are in the lib directory. The name of all libraries corresponds to artifactId-version.jar and their locations (inside the lib directory) groupId / artifactId / version. So I did the same for my mzmatch-1.2.13.jar file.

Besides adding a new dependency in the pom file, I added jar to the class-path in the Manifest.MF file. But the software still does not see my jar. What else should I do? Or am I not correctly adding my library?

+4
source share
1 answer

I assume this is the jar that you developed, and now you want Maven to pick it up as a dependency. To do this, you need to install it in the local Maven repository. Not the lib directory of your project, but the .m2 directory (possibly outside of your Windows home directory). You probably want to run this from the command line:

 mvn install:install-file -Dfile=<path-to-file> -DgroupId=mzmatch -DartifactId=mzmatch -Dversion=1.2.13 -Dpackaging=jar 

Check here for more information.

EDIT 1: I assume the OP is not working on a larger team. If dependency was required by anyone else in the development team, it would have to be deployed to a common internal artifact repository, such as Nexus or Artifactory . These applications have a page for downloading your artifacts.

EDIT 2: adding a library as a dependency in your pom.xml ensures that Maven will have it in the classpath when compiling code for this new project. If you want it there at run time (say, if you want an executable jar), and you want to have it in the Path class entry in MANIFEST.MF , then you can have Maven set up . This still does not put the mzmatch-1.2.13.jar in the same directory as your new project. If you do not want to do this manually, again Maven can do it for you .

+9
source

All Articles