Reputation: 91969
Consider this structure
project
pom.xml
component1/
pom.xml
persistence/pom.xml
business/pom.xml
rest/pom.xml
component2/
pom.xml
persistence/pom.xml
business/pom.xml
rest/pom.xml
When I try to do this, I get NullPointerException
[ERROR] Internal error: java.lang.NullPointerException -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.NullPointerException
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:167)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.NullPointerException
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:270)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
... 11 more
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/InternalErrorException
Can I not have a structure like this? I am using Maven 3.2.1
This is how component2/pom.xml
looks
<parent>
<groupId>com.org</groupId>
<artifactId>component2</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>persistence</artifactId>
<version>1.0-SNAPSHOT</version>
This is same as component1/pom.xml
except parent
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.org</groupId>
<artifactId>component1</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>persistence</artifactId>
<packaging>pom</packaging>
When I try to have a different module name, it works
Upvotes: 1
Views: 3293
Reputation: 16354
Not only maven gets will be confused with actual layering of your project, but some day you will get lost with both modules and you won't know which one is this or that.
So as @Raghuram pointed out you will need a unique identifier for each module, thus by having a unique groupId or unique artifcatId (Within scope of your project and even respecting other artifacts or you will get weird conflicts).
This is for uniqueness purpose, but some conventions should be followed and you will automatically get your self out of any troubles that could be caused by modules/projects naming:
goupId: A universally unique identifier for a project. It is normal to use a fully-qualified package name to distinguish it from other projects with a similar name (eg. org.apache.maven).
artifactId: The identifier for this artifact that is unique within the group given by the group ID.
Just follow those lines and you'll be not even safe but producing packages respecting practice rules.
Upvotes: 0
Reputation: 52645
As @jigar-joshi has indicated, maven needs a way to distinguish between the persistence
module of component1
and persistence
module of component2
. The way it does is by by the combination of groupId
and artifactId
. This combination needs to be unique for each persistence
module (or business
and rest
for that matter).
So, either each persistence
needs to have a unique groupId
(say com.org.component1
and com.org.component2
) or a unique artifactId
(component1-persistence
and component2-persistence
).
Upvotes: 1