Take the 2-minute tour ×

I am working in an established codebase with an existing standalone pom.xml.

Th intention is to incorporate a child project called "hive" in a subdirectory off of the parent one. Note: the hive/pom.xml does already exist and it works fine by itself.

So in the parent's pom.xml I added:


The problem is I basically lose ability to create the deployable jar from the parent project.

 stephenb@gondolin:/shared/git2/etl$ mvn package assembly:single
[INFO] Scanning for projects...

Project ID: com.myco.etl:etl
POM Location: /shared/git2/etl/pom.xml
Validation Messages:

    [0]  Packaging 'jar' is invalid. Aggregator projects require 'pom' as packaging.

Reason: Failed to validate POM for project com.myco.etl:etl at /shared/git2/etl/pom.xml

[INFO] Trace
    at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:404)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:272)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

It seems that maven wants me to create a parent pom that basically does nothing except define the dependency modules.

Well I can create a new pom.xml. But what I cannot do is to push the existing project files into a new subdirectory.

Is there a way to work around this? E.g. defining a submodule that lives at the same level (not subdir)? Or some other way to work with the existing dir structure?


Follow-up: Based on input that a module can simply be a file in local dir, I created another pom that calls the original one. The original one was renamed to pommod.xml and the new one shown below is called pom.xml.

    <name> ETL Helpers</name>

I ran "mvn compile package" But still get same error:

Project ID: com.myco:app_miner
POM Location: /shared/git2/etl/mycopom.xml
Validation Messages:


Reason: Failed to validate POM for project com.myco:app_miner at /shared/git2/etl/myco/pom.xml
share|improve this question

2 Answers 2

up vote 4 down vote accepted

To answer the question in the title of this post:

Yes, Maven can include parent and module at same directory level. I feel I first have to explain that a parent can have children and modules. Children and modules are not the same thing:

  • Child relationship is defined through parent in the child POM. If your parent is in the repo, that's that. If your parent is on the file system, you have to play with parent.relativePath for it to be found in the same folder
  • Module is defined through modules in the parent POM. Module typically contains a folder name, and the POM file is implied (e.g. <module>mod</module> is equivalent to <module>mod/pom.xml</module>). Hence a module in the same folder would be <module>pom1.xml</module> or something. (I called the module's POM file pom1.xml in this example, assuming that pom.xml is already taken by the parent — see what a mess we're getting ourselves in)

Let me quickly given an example where children and modules are distinctly different: you may have POMs to build the application of each of your teams. Each of your team may have webapps and backend apps. You may have parent POMs for webapps and backend apps. So some backend app would be a child of the POM for backend apps, while being a module of the team that is working on it.

A thing that strikes me is that you're talking about packaging. A parent POM (packaging pom) is typically just a blob of metadata and nothing else. If you want it to be something else you can still attach plugin executions to lifecycle phases. You can even run packaging plugins and attach the results to the artifact.

I didn't understand why hive cannot be a child (own folder, own POM in that folder), nicely one level down from the parent, how Maven had meant it to be. But it sounded to me like you could have some project, in whatever other directory, be dependent on the jar artifact in hive, and turn it into whatever assembly you want. So hive would be a dependency of the assembly project (let's say hive-assembly). That is getting to my next point...

The fact that Maven does in fact let you have parent and child in the same folder is not at all a good argument for doing so. It's only a matter of time for some part of Maven or one of its plugins is going to work against you. Maven is "convention over configuration", live by that!

share|improve this answer
I used your tip about having a module just be a pomXX.xml file. Still have issues and have updated the original post. –  javadba Apr 24 '13 at 18:57
Perhaps share just a little bit more POM detail of the projects involved. Which one are you building, how does it fail? –  Sander Verhagen Apr 27 '13 at 3:27
It seems necessary to have two different pom's; one for pom target as the parent and the other for the jar file. It then works - though v inconvenient. –  javadba Apr 27 '13 at 9:49
What are you missing if you declare the parent as pom? What does not work? I was thinking that through lifecycle binding of plugins you should be able to achieve what you want. (executions.execution.phase etc.) –  Sander Verhagen Apr 28 '13 at 4:45

This issue could be solved by using maven's Project Aggregation instead of Project Inheritance.

share|improve this answer

Your Answer


