java maven source目录,如何在Maven编译期间忽略Java Source目录?

I am trying to use the Lombok Maven Plugin to ensure the correct creation of Javadocs when using Lombok.

Lombok Maven introduces a new code generation goal, just prior to compilation. In my configuration, my sourceDirectory (Java with Lombok annotations, src/main/java) is processed to create Java (without Lombok annotations) in target/generated-sources/delombok.

However, every file in sourceDirectory now has a corresponding (identically named) file in target/generated-sources/delombok, resulting in compilation failures due to duplicate classes.

How can I tell the Java compiler to ignore the sources in sourceDirectory?

Note that the default Lombok Maven configuration would have the developer put Java (with Lombok annotations) in the src/main/lombok folder instead of src/main/java. However, I do not wish to do this because it confuses IDEs and my code compiles just fine (if I remove the Maven plugin).

Also note that simply redefining sourceDirectory will also upset IDEs (they no longer know where to find the Java source code!).

解决方案

I recently switched from using the flakey maven-exec-plugin approach to generate raw sources for the javadoc tool to using lombok-maven-plugin

My setup

All sources in src/main/java

Generated sources go in target/generated-sources/delombok

I initially ran into this problem but it seems to be an easy fix: Don't let lombok-maven-plugin add the delombok path to the compiler source paths with addOutputDirectoy. IE

org.projectlombok

lombok-maven-plugin

0.11.2.0

generate-sources

delombok

false

src/main/java

This seems to of solved the issue for now

EDIT: Bonus, how to generate proper javadocs with this setup

org.apache.maven.plugins

maven-javadoc-plugin

2.8.1

${project.version}

target/generated-sources/delombok

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值