This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Maven to automarically generate .aj files

Mar 17th, 2011, 04:36 AM

Hi guys,

I have the following problems: roo console is generating some .aj files for me in my project. Do I need those .aj files in the SVN?
1) Some of them I don't need and can safely delete and ignore from the SVN. The build then works fine and I can commit. But some of them cannot be deleted because

mvn clean install

will fail to compile the project. And the problem becomes really big when you have a CI server (like hudson or bamboo) that will not be able to run the roo console to generate those .aj files before the build. So it looks like I need them.
2) If I need them, does it really make sense to leave them in the SVN as they are every time regenerated? It looks ugly for me to bloat the SVN with additional files that are always regenerated.

Is there a Maven plugin that will generate the .aj files for me? Maybe I can bind it to any phase before compile?

You should not delete .aj files or nothing will work after a IDE or maven clean/rebuild of the project.
The compile goal in maven is made with aspecj compiler plugin, so you need those .aj to work properly. I recommend you to storage it on your SVN because is not totally autogenerated code, it relays on the roo script you made and may not be easy to restore.
Just as a note, remember that .aj files are managed by roo and if you change something you have to make a push-in refactor to the .java class or roo will overwrite your changes.

As general rule in my enterprise we have to keep in SVN everything needed to run the proyect without errors with maven. I think your approach is not the more correct one but if you want to, you could use http://mojo.codehaus.org/exec-maven-...exec-mojo.html to run a "roo" command on the project source and let all the .aj files get regenerated.