maven: generating several "artifacts" with a same pom file?

You could use the maven-assembly plugin. If the two artifacts have overlapping classes and updating one always requires to update the other one, then this is a good choice.

You have to think life cycle of the artifacts. Do both artifacts need to have the same version number? Do you want to publish a new version of p-core whenever you fix a bug in p-format? Is p-core useful on its own?

The assembly plugin should primarily be used to provide a different packaging for the same artifact, I guess.


Your life will be much easier if you simply break out p-format into a separate project that depends on p-core.

Although there are ways to publish multiple artifacts per project, Maven is designed around one artifact per pom/module (plus test artifacts). From experience, clever attempts to work around this design point will end up biting you eventually - usually in the form of an issue 6 months down the road where packaging won't work properly on someone's machine.

The scenario you describe fits well within the multi-project use case, and I'd suggest you go with the flow and make your future self happy.


You should create two separated projects (two separated POMs), but probably a good idea would be to create common parent for them that also aggregate them as modules. Look at Project Inheritance and Project Aggregation sections of Introduction to the POM for some basics.

In Maven, it's never a good idea to try to hack it so it produces many different artifacts from one POM.

Tags:

Maven