Reputation: 1092
I am working on a maven project. I want to create jar for the specific packages This is the project structure, I want to create jar containing only dca and common how do i achieve this.
myproject
|
--src
|
--main
|
--java
|
--common
--dca
--model
--resources
--test
--pom.xml
Can i achive this using maven-jar-plugin
Upvotes: 3
Views: 2532
Reputation: 9705
You could seperate your project into submodules, where you have two submodules:
These submodules would be seperate Maven artifacts in the same groupId
as you currently have. Any module containing submodules must be packaged as pom
, and hence cannot contain source code itself.
Code that depends on either package (for example, some kind of user interface, or web components) would reside in another submodule, say web
or gui
, and that submodule would have a Maven dependency on the common
or dca
artifact.
Summarising, your structure would look like this:
pom
war
jar
pom
jar
jar
Upvotes: 2
Reputation: 2394
maven-jar-plugin can be customized to include / exclude specific file. You can achieve this by configuring in pom.xml like below.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
.
.
<configuration>
<excludes>
<exclude>**/model/*</exclude>
</excludes>
</configuration>
.
.
</plugin>
Upvotes: 3