Maven multi module projects in eclipse
Hello,
I have a workspace in Jazz which has 1 parent project, with 2 modules.
/pom.xml
/child/pom.xml
/child2/pom.xml
When I load the component in RTC, it checks out all levels of the directory hierarchy, but eclipse only treats the top level directory as a maven project.
If I then import the child and child 2 directories as maven modules, these 2 modules are loaded as eclipse projects with everything that is wonderful about maven.
The problem is that the child and child2 projects are not jazz aware. If I change a file in child 1, it doesn't show in the pending changes view. If I refresh the parent project then it does. This workaround does the job for simple cases, but if I use eclipse to refactor the name or package of a class, then on refresh the parent treats the refactor as a delete + add rather than a rename.
Any suggestions as to how to get maven multi module projects working in RTC?
Thanks
Luke
I have a workspace in Jazz which has 1 parent project, with 2 modules.
/pom.xml
/child/pom.xml
/child2/pom.xml
When I load the component in RTC, it checks out all levels of the directory hierarchy, but eclipse only treats the top level directory as a maven project.
If I then import the child and child 2 directories as maven modules, these 2 modules are loaded as eclipse projects with everything that is wonderful about maven.
The problem is that the child and child2 projects are not jazz aware. If I change a file in child 1, it doesn't show in the pending changes view. If I refresh the parent project then it does. This workaround does the job for simple cases, but if I use eclipse to refactor the name or package of a class, then on refresh the parent treats the refactor as a delete + add rather than a rename.
Any suggestions as to how to get maven multi module projects working in RTC?
Thanks
Luke
12 answers
Eclipse's flat project structure does complicate things for multi-module Maven projects (the constraint is really with Eclipse, not Jazz SCM).
Some people recommend creating a flat Maven project structure, where the parent and child projects are at the same level in the file system, and the parent POM refers to the child projects using e.g. "../child". But that has some limitations, e.g. the Maven release plugin does not understand this flat structure.
I suggest keeping the nested structure in the file system and SCM, but using linked projects in Eclipse to get the nested projects to also show up at top-level.
Try:
- load your workspace as you do currently
- use File > Import > General / Existing Projects into Workspace
- browse to the root project directory
- ensure "Copy projects into workspace" is not checked
- select all the child projects, and click Finish
This will create Eclipse projects (at top level) for each of the nested projects, but the files/folders will be shared. Don't share these projects into SCM, since you don't want to duplicate the projects in the SCM system.
When you want to check-in your changes, you'll have to first use Refresh on the parent project to ensure it picks up the changes in the child projects. Or it may do this for you already (see the "Refresh automatically" option in the Workspace preference page).
I believe this is the approach used in M2Eclipse. See: http://m2eclipse.sonatype.org/working-with-multimodule-projects-in-m2eclipse.html
Some people recommend creating a flat Maven project structure, where the parent and child projects are at the same level in the file system, and the parent POM refers to the child projects using e.g. "../child". But that has some limitations, e.g. the Maven release plugin does not understand this flat structure.
I suggest keeping the nested structure in the file system and SCM, but using linked projects in Eclipse to get the nested projects to also show up at top-level.
Try:
- load your workspace as you do currently
- use File > Import > General / Existing Projects into Workspace
- browse to the root project directory
- ensure "Copy projects into workspace" is not checked
- select all the child projects, and click Finish
This will create Eclipse projects (at top level) for each of the nested projects, but the files/folders will be shared. Don't share these projects into SCM, since you don't want to duplicate the projects in the SCM system.
When you want to check-in your changes, you'll have to first use Refresh on the parent project to ensure it picks up the changes in the child projects. Or it may do this for you already (see the "Refresh automatically" option in the Workspace preference page).
I believe this is the approach used in M2Eclipse. See: http://m2eclipse.sonatype.org/working-with-multimodule-projects-in-m2eclipse.html
When you want to check-in your changes, you'll have to first use Refresh on the parent project to ensure it picks up the changes in the child projects. Or it may do this for you already (see the "Refresh automatically" option in the Workspace preference page).
I tried this approach, however the refresh option only picks up trivial updates. Using eclipse to perform refactoring causes issues though. If a class is moved or renamed, after the refresh this is detected as a delete and an add. I wasn't able to check in my change following this path.
A simpler approach would be to only select the child projects in the load dialog.
This assumes that there's no further nesting, and that the parent project isn't changed very often. You could use a separate Eclipse workspace to edit the parent project (I realize this is not ideal).
Thanks. I've tried this approach and it seems to be working so far.
I tried this approach, however the refresh option only picks up trivial updates. Using eclipse to perform refactoring causes issues though. If a class is moved or renamed, after the refresh this is detected as a delete and an add. I wasn't able to check in my change following this path.
One immediate problem of having RTC detect a rename or move as an add+delete is that it looses the history for the file, this is obviously undesirable. There is a work around that is somewhat tedious however...
If you know you need to move or rename a file (from a child project that is not directly monitored by RTC SCM) the only way to preserve a move/rename for that content is to use the SCM CLI. This can easily be done by using the lscm command.
> lscm move file.txt moved.txt
The above command is what you would use if your current working directory was the parent directory of a file that you are renaming from file.txt to moved.txt. The command will take full paths as well, if you wanted to move a file to another folder.
The other work around is to only load the 'child' project in which the rename/move is to take place in, this way that particular project will be properly tracked by the Jazz RTC SCM.
David, loading only the child modules is not enough when the children have a dependency on its parent. The parent dependency won't be found in those machines where it is not in the local maven repository. You may have not noticed it cause you probably have the parent in your local maven repository from previous builds already. At least that's what happened to me. Regards,
Lucas
Lucas
Hello:
Have there been any improvements related to maven support in RTC3.0?
If not, are there any whitepapers or other places that document best practices for using RTC with maven? We are currently using the SpringSource Toolsuite and the "p2 plugin" (2.0.0.2iFix4) and are seeing many of the issues described in this posting.
-Thanks
Maggie
Have there been any improvements related to maven support in RTC3.0?
If not, are there any whitepapers or other places that document best practices for using RTC with maven? We are currently using the SpringSource Toolsuite and the "p2 plugin" (2.0.0.2iFix4) and are seeing many of the issues described in this posting.
-Thanks
Maggie
Hi Maggie,
one additional resource I am aware of is: http://phkrief.wordpress.com/2010/09/24/when-maven-meets-rational-team-concert/ but it is probably RTC 2.0.
Thanks,
Ralph
one additional resource I am aware of is: http://phkrief.wordpress.com/2010/09/24/when-maven-meets-rational-team-concert/ but it is probably RTC 2.0.
Thanks,
Ralph
Hello:
Have there been any improvements related to maven support in RTC3.0?
If not, are there any whitepapers or other places that document best practices for using RTC with maven? We are currently using the SpringSource Toolsuite and the "p2 plugin" (2.0.0.2iFix4) and are seeing many of the issues described in this posting.
-Thanks
Maggie
I've found a couple of bugs that make it easier to handle maven modules : 108588 and 126332
I'm not sure they fix this particular problem though.
I'm currently looking at migrating an existing project from Subversion to Jazz SCM, and this is a blocker for us. Currently I can work around the problem by only importing the 'child' modules into eclipse as suggested above, but this won't work in the long term.
Is this a bug or would it be considered a new feature (or is there something I've missed)?
Thanks
-mike
I'm not sure they fix this particular problem though.
I'm currently looking at migrating an existing project from Subversion to Jazz SCM, and this is a blocker for us. Currently I can work around the problem by only importing the 'child' modules into eclipse as suggested above, but this won't work in the long term.
Is this a bug or would it be considered a new feature (or is there something I've missed)?
Thanks
-mike
Hi Maggie,
one additional resource I am aware of is: http://phkrief.wordpress.com/2010/09/24/when-maven-meets-rational-team-concert/ but it is probably RTC 2.0.
Thanks,
Ralph
Hello:
Have there been any improvements related to maven support in RTC3.0?
If not, are there any whitepapers or other places that document best practices for using RTC with maven? We are currently using the SpringSource Toolsuite and the "p2 plugin" (2.0.0.2iFix4) and are seeing many of the issues described in this posting.
-Thanks
Maggie
page 1of 1 pagesof 2 pages