Reputation: 685
I am developing a Java application in NetBeans and using maven for the dependencies. I have a bunch of jars located in a folder. These jars load other jars located in a path known to them. It seems to me that, when i load a local jar in maven, it is actually copying the jar to another location. The problem is that the moved jar can't find the other jars anymore because now the relative path to them jars is broken. Is it possible to use maven in such way that the included jars are not moved from their original place so they can find other jars? Or if this is not possible, is there a way to give maven an entire folder that contains subfolders, and if maven moves the entire folder, it would also move all the subfolders with the jars inside them? I am not sure if I was clear enough. I am also new to maven. It seems to me that ant is more flexible in this regard.
Edit: After reading the comments it seems I was not very clear. Basically the company I work for has two applications that share some common jars that load other jars with URLClassLoader. I don't want to distribute these common jars again, i want my second application to find and load those jars from the location where my first application has put them. I found a solution by using maven to import one jar that uses URLClassLoader with a hard-coded path to load the other jars.
Upvotes: 4
Views: 226
Reputation: 121
I have a module which pom file contains these lines in the beginning:
<groupId>com.domain.project</groupId>
<artifactId>MyFirstProgect</artifactId>
<packaging>jar</packaging>
<version>1.2.3-snapshot</version>
After I compile this project maven will put it into the local repository (mine is situated in the C:\Users\MyUser.m2\repository, in linux it should be somewhere in /home/myUser/.m2/repository).
Afterwards I can add a dependency in the second project like this:
<dependency>
<groupId>com.domain.project</groupId>
<artifactId>MyFirstProgect</artifactId>
<version>1.2.3-snapshot</version>
</dependency>
In my case this helped me. P.S. But this will lead the whole first project to be added as a dependency. So maybe this is not the perfect solution for you.
Upvotes: 0