Search code examples
eclipsemavenlombokaspectj-maven-plugin

ajc on Maven command line, but not in Eclipse in order to keep Lombok working


After successfully following this HowTo to integrate Lombok and AspectJ in a Maven build, my code doesn't compile anymore in eclipse. There are a lot of errors everywhere due to absence of getter/setter/constructors normally generated by Lombok.

My goal is to be able to use eclipse to develop using Lombok, and after that using a mvn clean install on command line in order to build.

I tried to skip AspectJ weaving in eclipse, but without success. Here is the profile I used to skip AspectJ:

<profile>
        <id>noAspectJ</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>aspectj-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>process-classes</id>
                            <phase>none</phase>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <compilerVersion>1.7</compilerVersion>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

Solution

  • The best solution I found was to remove the AspectJ plugin from my Eclipse, since it don't need it there. This way I could also avoid using a profile.

    But this could probably lead to some problem if I used the JUnit tests in eclipse.