简体   繁体   中英

exclude src/main/java from compiling with maven-compiler-plugin

Is anybody known how to remove a Source roots from maven-compiler-plugin ?

[DEBUG] Source roots:
[DEBUG]  C:\Workspace\Dev01\Internet_Login\src\main\java
[DEBUG]  C:\Workspace\Dev01\Internet_Login\target\generated-sources\delombok

Because I generate source with lombok-maven-plugin from C:\\Workspace\\Dev01\\Internet_Login\\src\\main\\java but the maven-compiler-plugin use both Source roots and i get a compilation error.

After compiling, I use Aspectj so I need to do that this way, 'cause Lombok and Aspectj are "incompatible".

Is anybody got a solution.

EDIT :

I've got a solution. Just define the sourceDirectory in build and the compiler gonna use this directory.

<build>
    <sourceDirectory>${project.build.directory}/generated-sources/delombok</sourceDirectory>
    ...
</build>

Thx

did you try with excludes ?

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
   <configuration>
        <excludes>
            <exclude>src/main/java/</exclude>
        </excludes>                  
    </configuration>
</plugin>

As Chrylis suggested, you ought to place any classes with Lombok annotations into src/main/lombok when using that plugin. This is clearly documented on its usage page .

There is also a sample project where you can see how plain Java classes without Lombok annotations are placed in src/main/java and the Lombok targets in src/main/lombok .

Just follow the instructions and you should be fine with regard to Maven Compiler plugin. As for AspectJ, it depends on how you want to weave your aspects (compile time, binary weaving, load time) and whether the aspects reside in the same or another module.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM