Skip to content

Add weaveOnly parameter to support Lombok integration#246

Open
youngledo wants to merge 2 commits into
mojohaus:masterfrom
youngledo:master
Open

Add weaveOnly parameter to support Lombok integration#246
youngledo wants to merge 2 commits into
mojohaus:masterfrom
youngledo:master

Conversation

@youngledo

Copy link
Copy Markdown

Correct fix for the "#231" issue.

Previously, @slachiewicz had done a "fix" using Copilot(#239). The author was skeptical about that fix and deleted the branch, and based on my testing(multi-module-aspect), the problem indeed still exists.

Here are the fixes I made after further analysis and testing.

Problem

When using AspectJ Maven Plugin with Lombok in multi-module projects, compilation fails because AspectJ tries to compile source files before Lombok annotation processing completes.

Solution

This PR adds a new weaveOnly parameter to the plugin. When set to true, the plugin will:

  • Skip source file compilation
  • Only perform weaving on already compiled class files
  • Allow other compiler plugins (like maven-compiler-plugin) to handle source compilation first

Usage Example

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <configuration>
        <weaveOnly>true</weaveOnly>
        <weaveDirectories>${project.build.outputDirectory}</weaveDirectories>
    </configuration>
</plugin>

Testing

Tested with a multi-module project using both Lombok and AspectJ. Build succeeds when:

  1. maven-compiler-plugin compiles sources first (with Lombok in annotationProcessorPaths)
  2. aspectj-maven-plugin runs in weaveOnly mode to weave the compiled classes

Related Issues

This addresses the common issue of integrating Lombok with AspectJ in Maven builds.


  - Add weaveOnly parameter to skip source compilation
  - When weaveOnly is true, only weave class files
  - This fixes compilation issues with Lombok in multi-module projects
  - Lombok annotation processing can complete before AspectJ weaving

@slachiewicz slachiewicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add unit/integration tests

…aveOnlyMojoTest)

  to validate weaveOnly parameter functionality for Lombok integration in multi-module projects.
@youngledo

Copy link
Copy Markdown
Author

please add unit/integration tests

Added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants