Maven: How do I exclude specific source files from javadoc?

。_饼干妹妹 提交于 2019-12-29 05:56:46

问题


I need to exclude specific source files (NOT just packages) from Javadoc using Maven. The <excludePackageNames> setting will not work for me: it only allows you to exclude certain packages. There's a <sourceFileExcludes> setting that has basically no documentation in the way of usage examples. It just says:

"sourceFileExcludes: exclude filters on the source files. These are ignored if you specify subpackages or subpackage excludes."

So, basically, I need to ignore all Java files that start with Mock, and also all Java files in two packages. Since sourceFileExcludes are ignored if I specify excludePackageNames, I can't combine them. So I tried this:

<sourceFileExcludes>
    <exclude>net/my/packagename/mock</exclude>
    <exclude>net/my/packagename/samples</exclude>
    <exclude>**/Mock*.java</exclude>
</sourceFileExcludes>

But it did not work. None of the intended files were excluded.

Anybody know how to use sourceFileExcludes?


回答1:


It might just not be working at the moment. There is bug logged in the plugin issue tracker - MJAVADOC-365




回答2:


And what about this?

<sourceFileExcludes>
    <exclude>net/my/packagename/mock/*.java</exclude>
    <exclude>net/my/packagename/samples/*.java</exclude>
    <exclude>**Mock*.java</exclude>
</sourceFileExcludes>



回答3:


You need to specify sourcepath also. Then sourceFileExcludes will work.

<sourceFileExcludes>
  <exclude>CryptoUtils.java</exclude>
</sourceFileExcludes>
<sourcepath>${basedir}/src/main/java/com/sdk/entity;${basedir}/src/main/java/com/sdk/main;${basedir}/src/main/java/com/sdk/util</sourcepath>
Note :

CryptoUtils is inside "/src/main/java/com/sdk/util"




回答4:


  <sourceFileIncludes>
    <includes>com/cod/user/**</includes>

   </sourceFileIncludes>
  <sourceFileExcludes>
 <exclude>com/cod/user/impl/**</exclude>

includes you want ,exclude else



来源:https://stackoverflow.com/questions/14518220/maven-how-do-i-exclude-specific-source-files-from-javadoc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!