Nick Williams
Nick Williams

Reputation: 3188

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

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?

Upvotes: 15

Views: 11396

Answers (4)

Hardy
Hardy

Reputation: 19109

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

Upvotes: 7

heru762004
heru762004

Reputation: 46

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"

Upvotes: 1

maximus
maximus

Reputation: 1

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

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

includes you want ,exclude else

Upvotes: -5

ben75
ben75

Reputation: 28706

And what about this?

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

Upvotes: 7

Related Questions