I have complex Maven project, which has a parent folder with parent pom.xml
and some subfolders for subprojects, each with its own pom.xml
.
When I checkout the parent folder from a SVN repository 'As maven projects', it correctly appears in the workspace each as separate project.
But now I made a checkout of the parent folder from other branch of project. I want to add this parent folder in the same manner to the current workspace. So I just select Import > Maven project
, get the same dialogs as due checkout from svn, Eclipse finds all pom files with proper hierarchy and ask me give other name to parent project, cause the same name alredy exists (trunc version of project), I give it other name. But after import I get only parent folder as maven project in eclipse, all other subprojects are simple located under parent project as its subfolders.
So, how can I import such project properlty? I just want all subprojects created as maven projects too.
Eclipse doesn't allow one project to be imported more than once, in your case from trunk and a branch. This article shows how you can bypass this limitation with a custom maven profile. Basically, the steps are:
Add the following profile to your parent pom.xml
<profiles>
<!-- Specific profile used to append a string to project name -->
<profile>
<id>append-to-project-name</id>
<activation>
<property>
<name>append.to.project.name</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<projectNameTemplate>
[artifactId]-${append.to.project.name}
</projectNameTemplate>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Before importing the project to Eclipse, let maven generate the project settings:
mvn eclipse:eclipse -Dappend.to.project.name=[your-branch-name]
Import the project to Eclipse as an existing project (not a maven project).
This should solve the naming issue.
As for import of child projects: I also have a parent maven project with child subprojects and use the m2e plugin for Ecplise. When I select Import > Existing Maven Project
, I can check both the parent and children. After import, I have both the parent project and each child imported independently. Screens:
So I hope this combined with the naming solution above should solve your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With