Well i have reusable code which i developed using Maven and the result artifact is a JAR.
Now to use it in another project , i have simply added the this dependency to that project's POM.xml,
but maven is not auto detecting and including the dependencies for the jar.
How do i go about do this ?
Appreciate any pointers in this regard .
You should try to build the developed(reusable) code with dependencies. I'm not quite sure if this will help (I had some issues with the build with dependencies, too), but I think it's worth a try. So you should add this to the pom.xml (of the reusable project):
<build> ... <plugins> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>fully.qualified.MainClass</mainClass> </manifest> </archive> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> </plugins> </build>
For details, have a look at this question and the maven-documenation
I solved this by manually adding the pom file for the jar I created.
ownjar.jar [artifact I created]
ownjar.pom [file I mannually created]
Then in the .pom file put in the dependencies.
<project> <dependencies> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.2.1</version> </dependency> </dependencies> </project>