2

I have a Spring Roo multi module project. I noticed that after including the jar/module containing my domain model in another project, the aspects had not been woven leaving me with domain classes without any usable getters/setters.

How can I make sure that aspects generated by Spring roo are woven by the dependent project?

EDIT: In order to be able to use Roo's aspects from another project, one needs to include the aspectJ plugin in the dependent project. Note that compile time loading is not needed that way.

balteo
  • 23,602
  • 63
  • 219
  • 412

1 Answers1

1

You need to include the aspectj maven plugin in the pom:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.4</version>
            <!-- NB: do not use 1.3 or 1.3.x due to MASPECTJ-90 and do not use 1.4
                due to declare parents issue -->
            <dependencies>
                <!-- NB: You must use Maven 2.0.9 or above or these are ignored (see
                    MNG-2972) -->
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjrt</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjtools</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>test-compile</goal>
                    </goals>
                    <!-- NB: force aspect compile before normal compile, required for 1.3+
                        see: MASPECTJ-13, MASPECTJ-92 -->
                    <phase>process-sources</phase>
                </execution>
            </executions>
            <configuration>
                <outxml>true</outxml>
                <aspectLibraries>
                    <aspectLibrary>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-aspects</artifactId>
                    </aspectLibrary>
                </aspectLibraries>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>
Solubris
  • 3,603
  • 2
  • 22
  • 37
  • Is this the default configuration provided by Roo or have you modified it? – balteo Nov 20 '12 at 10:53
  • Thanks Lithium: can you please let me know what are those parts of the config that have changed? – balteo Nov 20 '12 at 12:30
  • Another question: do I need to include this in the POM of the domain model project or in the project that depends on the domain model project? – balteo Nov 20 '12 at 16:12
  • It was updated to use plugin version 1.4. It would definitely need to go in the domain project. Possibly in the dependant projects as well; not certain; give it a go.. – Solubris Nov 20 '12 at 17:07
  • I confirm one needs the aspectj plugin in the dependent project as well. – balteo Jan 02 '13 at 15:28