As a Spring and/or ROO user, I would like to be able to have AspectJ and still be able to compile Groovy files

Details

Description

I have a very large project with some groovy files. I would love to play around with ROO or just use AspectJ for other parts of my project. If I add AspectJ support, my groovy files get treated like java files.

Right now you cannot have a single project that mixes Java, AspectJ and Groovy.

With groovy eclipse installed, the Eclipse java Compiler will understand groovy code if the project has the groovy nature. When you add the AspectJ nature you get the AspectJ compiler - this compiler does not understand groovy code. When you switch the AspectJ nature off again, you go back to the standard compiler which is groovy aware.

As more people hit the requirement in that bug, I increase the priority of getting that work done. I know it is important.

Andy Clement
added a comment - 12/Nov/09 9:55 AM Unfortunately, this is a known issue under AspectJ bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=287092
Right now you cannot have a single project that mixes Java, AspectJ and Groovy.
With groovy eclipse installed, the Eclipse java Compiler will understand groovy code if the project has the groovy nature. When you add the AspectJ nature you get the AspectJ compiler - this compiler does not understand groovy code. When you switch the AspectJ nature off again, you go back to the standard compiler which is groovy aware.
As more people hit the requirement in that bug, I increase the priority of getting that work done. I know it is important.

I stumbled on this bug just now while trying to un-bang my head around something...

I'm not sure if this is keeping me from what I'm trying to do, but I'm trying to put together a Spock Roo add-on, and it needs the GMaven plugin, version 1.3, from Codehaus, to do its work.

So far, I have it working to a degree. I get to the point where I'm testing basic POJOs fine, but when I use a @ContextConfiguration test, I get this error:

java.lang.IllegalStateException: Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)
at foo.db.BlogEntry_Roo_Entity.entityManager_aroundBody0(BlogEntry_Roo_Entity.aj:91)
at foo.db.BlogEntry.entityManager(BlogEntry.java:1)
at foo.db.BlogEntry.persist(BlogEntry.java:1)
at foo.db.BlogEntryTest.persisting a blog entry(BlogEntryTest.groovy:30)

To me, it's important that we are able to add groovy and other languages to a Roo and/or Spring project this way, at least for testing. Spock takes the place of a number of testing frameworks, is easy to read, and just rocks. Ok, I've been swayed by a demo from the creator of the project.

Just because Roo started as a "Java-based productivity tool" doesn't mean to me that we should limit it. So I'm commenting and voting this up.

I have hit this problem, although I'm not using Roo.
I have a mixed Java/Groovy project in which I only use Groovy for tests; production code is all Java. Quite a common setup, I think.
I'm trying to introduce AspectJ and, while it's fine if I just build using Maven (using the groovy-eclipse compiler and aspectj-maven-plugin from codehaus) I've found that STS/Eclipse automatically picks up the fact that AspectJ is in use – not sure whether this is from the aspectj-maven-plugin, or from Eclipse spotting an .aj file – and adds the AspectJ nature to the projects… which means it now can't compile the Groovy code. I can remove the AspectJ nature but it's re-added every time I update the project from the Maven POM unless I uninstall the Maven Integration for AJDT plugin.

So… if there's any way SpringSource/Pivotal could get someone to work on this, it'd be excellent news both for Roo users and, more generally, anyone who wants to use AspectJ with Groovy!

Michael Bannister
added a comment - 17/Mar/15 1:58 AM I have hit this problem, although I'm not using Roo.
I have a mixed Java/Groovy project in which I only use Groovy for tests; production code is all Java. Quite a common setup, I think.
I'm trying to introduce AspectJ and, while it's fine if I just build using Maven (using the groovy-eclipse compiler and aspectj-maven-plugin from codehaus) I've found that STS/Eclipse automatically picks up the fact that AspectJ is in use – not sure whether this is from the aspectj-maven-plugin, or from Eclipse spotting an .aj file – and adds the AspectJ nature to the projects… which means it now can't compile the Groovy code. I can remove the AspectJ nature but it's re-added every time I update the project from the Maven POM unless I uninstall the Maven Integration for AJDT plugin.
So… if there's any way SpringSource/Pivotal could get someone to work on this, it'd be excellent news both for Roo users and, more generally, anyone who wants to use AspectJ with Groovy!

Making AJDT and Groovy-Eclipse play nice with each other on the same project is a bigger deal and we don't have any plan to work on this. But from your comment it sounds like removing the AJDT nature from the project is a usable workaround - if it would not get added back each time you update the pom file. Would that work for you? We could take a look at modifying the AJDT maven integration to avoid this behavior, if that helps. What do you think?

Martin Lippert (c)
added a comment - 26/Mar/15 7:32 AM Making AJDT and Groovy-Eclipse play nice with each other on the same project is a bigger deal and we don't have any plan to work on this. But from your comment it sounds like removing the AJDT nature from the project is a usable workaround - if it would not get added back each time you update the pom file. Would that work for you? We could take a look at modifying the AJDT maven integration to avoid this behavior, if that helps. What do you think?

Yes, that could be a decent workaround!
Meanwhile, though, I've moved to using maven-antrun-plugin and the iajc Ant task to do what I need (also because I couldn't figure out how to get aspectj-maven-plugin just to weave and not to recompile all my regular classes). So I've found a solution, for now.

Michael Bannister
added a comment - 26/Mar/15 11:05 AM Yes, that could be a decent workaround!
Meanwhile, though, I've moved to using maven-antrun-plugin and the iajc Ant task to do what I need (also because I couldn't figure out how to get aspectj-maven-plugin just to weave and not to recompile all my regular classes). So I've found a solution, for now.