Reputation: 5763
Suppose we have following packages in our project
org.xxx.dao, org.xxx.service, org.xxx.service.impl
all the package are in ther source folder src/main/java
can i assembly packages into seprated jars,(xxx-dao.jar,xxx-service.jar,xxx-service-impl.jar)?
Upvotes: 3
Views: 1167
Reputation: 328614
You can use the standard maven-jar-plugin
for this:
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>dao</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<archive>
<index>true</index>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
<classifier>dao</classifier>
<includes>
<include>org/xxx/dao/**/*</include>
</includes>
</configuration>
</execution>
<execution>
<id>service</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<archive>
<index>true</index>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
<classifier>service</classifier>
<includes>
<include>org/xxx/service/**/*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
This gives you one JAR with everything and then several JARs with only the selected content which you can select with a classifier in your Maven POMs.
If you want to omit the default JAR (which contains everything), then you replace one <id>
with <id>default-jar</id>
and add an <excludes>
element because the default JAR includes everything, so you have to get rid of anything that you don't want.
Upvotes: 6
Reputation: 4599
maven-assembly plugin is not intended for this kind of tasks, see its features. If you have the source codes, then I would suggest copying them into a module of your project.
But if you want to do it with maven-assembly plugin, then I think you can do it by creating separate descriptor components and defining which files to include in which assembly. You can define source files to be included in includes
tags under sources definition.
Upvotes: 1