How to enable jars that load other jars in maven?

I am developing a Java application in NetBeans and using maven for dependencies. I have a bunch of cans located in a folder. These banks load other banks located on the path they know. It seems to me that when I load the local jar in maven, it actually copies the jar to a different location. The problem is that the moved jar can no longer find other jars because now the relative path of jars to them is broken. Is it possible to use maven in such a way that the included jars are not moved from their original location so that they can find other jars? Or if that is not possible, is there a way to give maven a complete folder containing subfolders and if maven moves the entire folder it also moves all subfolders with jars inside them? I'm not sure if I was clear enough. I am also new to maven. I think,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 apps that have shared jars that load other jars with URLClassLoader. I don't want to distribute these common jars again, I want my second app to find and download these jars from where the first app put them. I found a solution using maven to import one jar that uses a URLClassLoader with a hardcoded path to load other jars.

+3


source to share


1 answer


I have a module that pom file contains these lines at the beginning:

<groupId>com.domain.project</groupId>
<artifactId>MyFirstProgect</artifactId>
<packaging>jar</packaging>
<version>1.2.3-snapshot</version>

      

After compiling this project, maven will put it in the local repository (mine is in the repository C: \ Users \ MyUser.m2 \, on linux it should be somewhere in /home/myUser/.m2/repository).



Subsequently, 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, it helped me. Postscript But this will cause the entire first project to be added as a dependency. So it might not be the perfect solution for you.

0


source







All Articles