Spring Tool Suite
  1. Spring Tool Suite
  2. STS-629

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

    • Type: New Feature New Feature
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: ROO
    • Labels:
      None

      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.

      Create new Groovy project "GroovyProject"
      Create new Groovy Class "com.test.Animal"

      package com.test
      
      class Animal {
      	String name
      	
      	public String doThis() {
      		this.getName()
      	}
      }
      

      Everything is fine here.

      Now,
      Right click GroovyProject > Configure > Convert to AspectJ Project
      Project > Clean

      All hell breaks loose.

      If you now
      Right click GroovyProject > AspectJ Tools > Remove AspectJ Capability

      Everything is back to normal.

      Attached is a fresh STS 2.2.1 Groovy project for you to play with.

        Activity

        Hide
        Andy Clement (c) added a comment -

        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.

        Show
        Andy Clement (c) added a comment - 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.
        Hide
        Rick Holland added a comment -

        Agreed, would love to be able to use Groovy with Roo.

        Rick Holland

        Show
        Rick Holland added a comment - Agreed, would love to be able to use Groovy with Roo. Rick Holland
        Hide
        Kenneth Rimple added a comment -

        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.

        My gmaven config here (everything else seems to work):

        <plugin>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <version>1.3</version>
            <configuration>
                <providerSelection>1.7</providerSelection>
        
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>generateStubs</goal>
              <goal>compile</goal>
              <goal>generateTestStubs</goal>
              <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.gmaven.runtime</groupId>
                    <artifactId>gmaven-runtime-1.7</artifactId>
                    <version>1.3</version>
                    <exclusions>
                        <exclusion>
                            <groupId>org.codehaus.groovy</groupId>
                            <artifactId>groovy-all</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-all</artifactId>
                    <version>1.7.5</version>
                </dependency>
            </dependencies>
        </plugin>
        

        FYI, here's the test and entity:

        package foo.db
        
        import org.springframework.test.context.ContextConfiguration
        import org.springframework.transaction.annotation.Transactional
        import spock.lang.Specification
        
        @ContextConfiguration(locations = "classpath:META-INF/spring/*.xml")
        
        class BlogEntryTest extends Specification {
        
            @Transactional
            @spock.lang.IgnoreRest
            def "persisting a blog entry"() {
        
                given:
                BlogEntry entry = new BlogEntry(
                        title: "My big title",
                        teaser: "This is gonna be big",
                        displayed: true,
                        postDate: new Date())
        
                when:
                entry.persist()
                entry.flush()
        
                then:
                null != entry.id
        
            }
        }
        
        package foo.db;
        
        import org.springframework.roo.addon.entity.RooEntity;
        import org.springframework.roo.addon.javabean.RooJavaBean;
        import org.springframework.roo.addon.tostring.RooToString;
        import javax.validation.constraints.Size;
        import java.util.Date;
        import javax.persistence.Temporal;
        import javax.persistence.TemporalType;
        import org.springframework.format.annotation.DateTimeFormat;
        
        @RooJavaBean
        @RooToString
        @RooEntity
        public class BlogEntry {
        
            @Size(max = 80)
            private String title;
        
            @Size(max = 300)
            private String teaser;
        
            private String entry;
        
            @Temporal(TemporalType.TIMESTAMP)
            @DateTimeFormat(style = "SS")
            private Date postDate;
        
            private Boolean displayed;
        }
        
        Show
        Kenneth Rimple added a comment - 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. My gmaven config here (everything else seems to work): <plugin> <groupId>org.codehaus.gmaven</groupId> <artifactId>gmaven-plugin</artifactId> <version>1.3</version> <configuration> <providerSelection>1.7</providerSelection> </configuration> <executions> <execution> <goals> <goal>generateStubs</goal> <goal>compile</goal> <goal>generateTestStubs</goal> <goal>testCompile</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>org.codehaus.gmaven.runtime</groupId> <artifactId>gmaven-runtime-1.7</artifactId> <version>1.3</version> <exclusions> <exclusion> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>1.7.5</version> </dependency> </dependencies> </plugin> FYI, here's the test and entity: package foo.db import org.springframework.test.context.ContextConfiguration import org.springframework.transaction.annotation.Transactional import spock.lang.Specification @ContextConfiguration(locations = "classpath:META-INF/spring/*.xml") class BlogEntryTest extends Specification { @Transactional @spock.lang.IgnoreRest def "persisting a blog entry"() { given: BlogEntry entry = new BlogEntry( title: "My big title", teaser: "This is gonna be big", displayed: true, postDate: new Date()) when: entry.persist() entry.flush() then: null != entry.id } } package foo.db; import org.springframework.roo.addon.entity.RooEntity; import org.springframework.roo.addon.javabean.RooJavaBean; import org.springframework.roo.addon.tostring.RooToString; import javax.validation.constraints.Size; import java.util.Date; import javax.persistence.Temporal; import javax.persistence.TemporalType; import org.springframework.format.annotation.DateTimeFormat; @RooJavaBean @RooToString @RooEntity public class BlogEntry { @Size(max = 80) private String title; @Size(max = 300) private String teaser; private String entry; @Temporal(TemporalType.TIMESTAMP) @DateTimeFormat(style = "SS") private Date postDate; private Boolean displayed; }

          People

          • Assignee:
            Andy Clement (c)
            Reporter:
            Scott Murphy
          • Votes:
            11 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              First Response Date: