I have an unresolvable dependency issue in a Maven project; different pieces of code depend on different versions of dependency A (i.e. most code needs A:0.15; some needs A:0.18). Fortunately, the code is completely separable; that is, the parts that depend on the two different versions can be split into two different projects with two different pom files.

But I'd like to take this opportunity to learn about Maven modules. I could split my project into two modules and compile them separately. But, in six months or so, I hope that this dependency issue will be resolved, and the project will go back to being unitary with no modules. So, what I would like to do is to have a parent project that is packaged as a jar, and then a child module that also compiles into a separate jar. The child project will simply swap out the dependencies.

I really don't know how to make this work, or if it is even good practice to do so. All the examples of module-ing with Maven have the parent class packaged as pom instead of jar.

How can I set up my parent and child pom file so that both of them can be packaged into separate jars, and the child pom is identical to the parent except for a single dependency version? Should I be doing this?

  • see Where does my tool question go?
    – gnat
    Commented Jan 22, 2019 at 16:08
  • @gnat I don't really see how that is relevant. I'm not asking about tools, I'm using Maven. I'm asking about how to set up a pom file.
    – kingledion
    Commented Jan 22, 2019 at 16:15

1 Answer 1


You should not be doing this. Parent POMs have pom as their packaging, and even if you make it work technically, you break expectations and many Maven plugins will not forgive you.

I would refactor the code into the two modules (as you said), and if the issue is resolved someday, you can restructure the two modules into one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.