Monday, December 2, 2013

Compiling aspectj files declared under maven java project

I've aspectj file under onramp maven project at the location, onramp\src\main\aspects\com\hp\cloudprint\api\onramp\metrics\MonitoringAspect.aj

The below declaration in onramp\pom.xml is required to compile the above file.


<build>
    <finalName>onramp</finalName>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.2</version>
            <configuration>
                <aspectDirectory>src/main/aspects</aspectDirectory>
                <source>1.6</source>
                <target>1.6</target>
                <!-- <outxml>true</outxml>
                <showWeaveInfo>true</showWeaveInfo>
                <Xlint>warning</Xlint>
                <verbose>true</verbose> -->
            </configuration>
            <executions>
                <execution>
                    <phase>process-sources</phase>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.6.5</version>
        <scope>runtime</scope>
    </dependency>
</dependencies>

   

   

   

When onramp>mvn clean install command is run the compiled aspectj file is generated at the location, onramp\target\classes\com\hp\cloudprint\api\onramp\metrics\MonitoringAspect.class

Followers