Reputation: 1017
I have created several projects in Java that I would like to package as group. I have created a wrapper project to hold these. So we pretty much have a set up like this
We are packaging a project that uses the WrapperProject and my supervisors would like to package the third party dependencies in separate file than the WrapperProject.jar that would be produced during the assembly.
I wonder whether that is possible and how? I have been looking into the Maven dependency plugin but have not used it before and so I am not quite sure how it works. At the end of the day I would like to have a lib folder and a Jar file that would look something like this.
Lib - ThirdPartyProject1.jar - ThirdPartyProject2.jar - ThirdPartyProject3.jar
WrapperProject.jar - Project1.jar - Project2.jar - Project3.jar
Upvotes: 1
Views: 587
Reputation: 392
If the Third party jar is available in maven repository, then you can use normal maven build command "mvn package", or else the jar is project specific custom one then you should install that jar into your maven local repository using the command "mvn install". Refer the below link,
http://www.mkyong.com/maven/how-to-include-library-manully-into-maven-local-repository/
Once done then include that dependency and the below build configuration into your pom.XML, Then change the main-class.
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
Now build the project then you will get two jar one is without dependency & another one is with dependency classes.
Upvotes: 0
Reputation: 12266
You can use the copy resources plugin to make a /target/lib folder. Or you can use the assembly plugin to create a jar/zip of all the dependencies. I'm not sure what you are doing with the lib directory, but it might be more convenient to have it as a zip file.
Upvotes: 1