Swapnil Hadge
Swapnil Hadge

Reputation: 57

How to create a custom pom dependecy which contains multiple jars? Is it possible?

My project contains around 30 jars which does not have a maven dependency settings. So I have to manually add the jars in th local maven repo and then use the custom maven dependencies to project. However I have to add 30 dependencies in the POM file which I feel might not be a good way to do it. Is there any way so that those all 30 jar files can be added with a single pom dependency?

For adding the jar in the local maven repo and then use the dependency, I am using below method:

Ex:

$ mvn install:install-file -Dfile=c:\kaptcha-{version}.jar -DgroupId=com.google.code 
    -DartifactId=kaptcha -Dversion={version} -Dpackaging=jar

and then use the dpendency as below:

 <dependency>
          <groupId>com.google.code</groupId>
          <artifactId>kaptcha</artifactId>
          <version>2.3</version>
 </dependency>

Kapcha jar is just for reference and I have dfferent 30 jars to add in repo and use in the project.

Please help.

Upvotes: 0

Views: 99

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35901

First of all, I would check whether you can draw a fair amount of these dependencies form MavenCentral (avoiding the manual hassle).

Secondly, if you are in a company with more than two Java developers, you should set up a Nexus or Artifactory server to handle the JARs. So no manual installation any more.

After saying this: You can create a POM that contains a list of dependencies. If you add this POM as dependency in your project, then all the dependencies of the POM will become (transitive) dependencies of your project.

Upvotes: 1

Related Questions