views:

608

answers:

2

Spring Roo can be use in existing projects that follow standard maven layout. So far this appears to mean that projects that doesn't use maven are out of luck.

I am wondering what (if any) are the options for such existing projects.

Re-arrange the project layout to conform to Maven layout? This appears to be very difficult path for projects with years of history in CVS due to the fact that method for moving around directories in CVS is extremely invasive.

Are there any other options like modifying Maven configuration to work with non-standard layouts? What I recall from my earlier reading about this subject, Maven's CoC approach doesn't favor such non-standard layouts.

Edit:

Rich's answer below shows that over-riding the defaults in super-pom is trivial. That leaves us with the question whether Spring Roo will play nicely with such modifications. This is doubtful given the fact the Spring Roo doesn't use Maven itself.

Edit:

Rich's updated answer shows that, by default, ROO will use hard coded paths and will not pick modifications in your pom.xml So answer so far appears to be that it isn't possible out-of-the-box but can be done by some custom coding (or asking ROO team to support this)

+1  A: 

You can modify Maven to use a different set of conventions. The standard set are inherited from the Maven super POM and can be overridden by redefining the relevant property.

For example, to change the sources directory from src/main/java to src, the test directory to test-src, and the resources directory from src/main/resources to resources you would set the following in your POM:

<build>
  <sourceDirectory>src</sourceDirectory>
  <testSourceDirectory>test-src</testSourceDirectory>
  <resources>
    <resource>
      <directory>resources</directory>
    </resource>
  </resources>
</build>

Be aware that a few plugins might not use the standard properties to access the locations (e.g. hardcoding target/classes instead of using ${project.build.outputDirectory}, so you might have the odd problem.


Update: It looks like Roo currently has these properties hardcoded. You may be able to replace the MavenPathResolver or add an additional resolver to use the custom properties.

If this is a real problem for you, you can raise a request to get the MavenPathResolver modified to allow custom locations.

Rich Seller
Any idea whether Spring ROO will work with such modified configurations? I think Spring ROO itself doesn't use Maven but the generated projects do use it.
Tahir Akhtar
Thanks for the update, Rich.
Tahir Akhtar
Where do we add the additional resolver?
Tahir Akhtar
Sorry I don't know how you would do that. It's a guess that you can based on Spring's approach elsewhere. You could try debugging Roo to see how the MavenPathResolver is contributed.
Rich Seller
+1  A: 

There's no reason we (the Roo team) cannot make the MavenPathResolver allow custom paths to be used, and one of the intentional reasons I created a PathResolver abstraction was to support customisation of common path locations not only to Maven non-default locations but also to other build systems like Ant+Ivy. all base Roo add-ons have been written to use the PathResolver so it shouldn't be a major effort to support this. Please add an enhancement request to the Roo Jira instance if you'd still like this support.

Ben Alex
Thanks Ben for the detailed answer. I have switched jobs since I asked this question. At my previous Job I was evaluating possibility of using Roo in an existing project that was using both AspectJ and Spring independently. But the project layout was not based on Maven. Hence the question.
Tahir Akhtar