使用Maven-compiler-plugin从编译中排除src/main/java [英] exclude src/main/java from compiling with maven-compiler-plugin

查看:944
本文介绍了使用Maven-compiler-plugin从编译中排除src/main/java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人知道如何从maven-compiler-plugin中删除Source根目录?

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

因为我从 C:\ Workspace \ Dev01 \ Internet_Login \ src \ main \ java 使用lombok-maven-plugin生成了源,但是maven-compiler-plugin同时使用了Source根目录,因此我得到了编译错误.

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.

编译后,我使用Aspectj,所以我需要这样做,因为Lombok和Aspectj是不兼容的".

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

有人解决吗?

我有一个解决方案.只需在build中定义sourceDirectory,编译器便会使用该目录.

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

推荐答案

正如Chrylis所建议的那样,使用该插件时,应将带有Lombok批注的所有类放入src/main/lombok中.它的使用页面上明确记录.

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.

还有一个示例项目在这里,您可以看到如何在src/main/java中放置没有Lombok注释的普通Java类,并在src/main/lombok中放置Lombok目标.

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.

只需按照说明进行操作,就可以使用Maven Compiler插件了.至于AspectJ,这取决于您要如何编织方面(编译时,二进制编织,加载时间)以及这些方面是驻留在相同模块中还是在另一个模块中.

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.

这篇关于使用Maven-compiler-plugin从编译中排除src/main/java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆