Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aspectj-maven-plugin not executed?

Tags:

maven

aspectj

I am having problems building an AspectJ project using the aspectj-maven-plugin

the project has only one aspect:

src/main/java/org/lightforge/config/ConfigurationAspect.aj

ConfigurationAspect.aj does some members introduction according to Ch5 of AspectJ in Action 2nd Ed.

I am using Eclipse with AJDT and set pom.xml according to http://mojo.codehaus.org/aspectj-maven-plugin/

Although, when I run Maven install (Run As -> Maven Install), apparently aspectj-maven-plugin:compile is never executed.

Following is my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>lightforge</groupId>
<artifactId>lightforge-config</artifactId>
<version>0.0.6-SNAPSHOT</version>
<name>lightforge-config</name>
<dependencies>
    <dependency>
        <groupId>commons-configuration</groupId>
        <artifactId>commons-configuration</artifactId>
        <version>1.9</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.6</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.6.11</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjtools</artifactId>
        <version>1.6.11</version>
    </dependency>
</dependencies>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.4</version>
                <configuration>
                    <outxml>true</outxml>
                    <ajdtBuildDefFile>build.ajproperties</ajdtBuildDefFile>
                    <verbose>true</verbose>
                    <aspectDirectory>src/main/java</aspectDirectory>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
</project>

This is my build.ajproperties:

src.includes = src/main/java/,\
           src/main/resources/,\
           src/test/java/,\
           src/test/resources/
src.excludes = src/main/resources/**,\
           src/test/resources/**

Finally, this is the Build Log:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building lightforge-config 0.0.6-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ lightforge-config ---
[debug] execute contextualize
[WARNING] Using platform encoding (US-ASCII actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ lightforge-config ---
[WARNING] File encoding has not been set, using platform encoding US-ASCII, i.e. build is platform dependent!
[INFO] Compiling 2 source files to /Users/jjcamachosanchez/Dropbox/Jhon/Dev/Eclipse/workspace/lightforge-config/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /Users/jjcamachosanchez/Dropbox/Jhon/Dev/Eclipse/workspace/lightforge-config/src/main/java/org/lightforge/config/TestSubject.java:[12,9] cannot find symbol
symbol  : method getPropertyInt(java.lang.String)
location: class org.lightforge.config.TestSubject
[ERROR] /Users/jjcamachosanchez/Dropbox/Jhon/Dev/Eclipse/workspace/lightforge-config/src/main/java/org/lightforge/config/TestSubject.java:[16,9] cannot find symbol
symbol  : method getPropertyLong(java.lang.String)
location: class org.lightforge.config.TestSubject
[ERROR] /Users/jjcamachosanchez/Dropbox/Jhon/Dev/Eclipse/workspace/lightforge-config/src/main/java/org/lightforge/config/TestSubject.java:[20,9] cannot find symbol
symbol  : method getPropertyString(java.lang.String)
location: class org.lightforge.config.TestSubject
[INFO] 3 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.286s
[INFO] Finished at: Mon Jul 29 00:14:56 COT 2013
[INFO] Final Memory: 9M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project lightforge-config: Compilation failure: Compilation failure:
[ERROR] /Users/jjcamachosanchez/Dropbox/Jhon/Dev/Eclipse/workspace/lightforge-config/src/main/java/org/lightforge/config/TestSubject.java:[12,9] cannot find symbol
[ERROR] symbol  : method getPropertyInt(java.lang.String)
[ERROR] location: class org.lightforge.config.TestSubject
[ERROR] /Users/jjcamachosanchez/Dropbox/Jhon/Dev/Eclipse/workspace/lightforge-config/src/main/java/org/lightforge/config/TestSubject.java:[16,9] cannot find symbol
[ERROR] symbol  : method getPropertyLong(java.lang.String)
[ERROR] location: class org.lightforge.config.TestSubject
[ERROR] /Users/jjcamachosanchez/Dropbox/Jhon/Dev/Eclipse/workspace/lightforge-config/src/main/java/org/lightforge/config/TestSubject.java:[20,9] cannot find symbol
[ERROR] symbol  : method getPropertyString(java.lang.String)
[ERROR] location: class org.lightforge.config.TestSubject
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Please Help me,

Jhon

like image 321
Jhon Camacho Avatar asked Feb 15 '23 18:02

Jhon Camacho


2 Answers

Jon, Not sure if you got your answer and for reasons I cannot explain, removing the pluginManagement tag around the plugins seems to work.

like image 140
zoostar Avatar answered Feb 26 '23 23:02

zoostar


You have to disable maven-compiler-plugin so that ajc compiler is used and not javac:

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <executions>
                <execution>
                    <id>default-testCompile</id>
                    <phase>none</phase>
                </execution>
                <execution>
                    <id>default-compile</id>
                    <phase>none</phase>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
like image 39
Jonatan Cloutier Avatar answered Feb 26 '23 21:02

Jonatan Cloutier