开发者

selective build with maven

I have maven con开发者_开发百科figured for my java project to build single jar with all the classes. Is it possible to select certain classes and build a separate jar out of them?


On the usage page of the maven-jar-plugin, you can find a sample configuration for this under the subheading Additional attached JAR.


Create a separate module for the 'lib' classes and set is as dependency of the project module.


Maven dictates one-to-one relationship between pom.xml and binary file it produces. In other words if you want to create several jar files you need several pom files: pom per jar.

So, just split your project. BTW sometimes it is a good practice. Really if some your classes can exist without others they do not depend on others and therefore can live in other project.

Projects can depend on others and can be hierarchical, i.e. have parent project. So, you can create parent project and several children under it.


This seems to be some kind of maven FAQ. You can find a detailed answer in the Sonatype (maven contributer) Blog:

How to Create Two JARs from One Project (…and why you shouldn't)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜