简体   繁体   English

如何让Ant Javadoc类排除两个文件?

[英]How can I make an Ant Javadoc class exclude two files?

I am documenting some Java webservices and the supporting datatypes. 我正在记录一些Java Web服务和支持数据类型。 There are two services that I do not want documented. 我不想记录两种服务。 What is the correct way to exclude a small number of files from the Ant javadoc task? 从Ant javadoc任务中排除少量文件的正确方法是什么?

I have tried several iterations using files or filesets nested under sourcepath or sourcefiles with various combinations of include and exclude. 我已尝试使用嵌套在sourcepath或sourcefiles下的文件或文件集进行多次迭代,并使用include和exclude的各种组合。

The base target I have defined correctly documents all of my webservices: 我已正确定义的基本目标记录了我的所有Web服务:

    <target name="javadoc.webservices" description="Generate the documentation for companyproject webservices">
    <delete dir="docs/webservices" failonerror="true"/>
    <mkdir dir="docs/webservices"/>
    <javadoc packagenames="com.company.project.webservices,com.company.project.models.*"
             defaultexcludes="yes"
             destdir="docs/webservices"
             author="true"
             version="true"
             use="true"
             windowtitle="company project Webservices">
        <doctitle><![CDATA[<h1>company project Webservices</h1>]]></doctitle>
        <bottom><![CDATA[<i>Copyright &#169; 2011 company Corp. All Rights Reserved.</i>]]></bottom>
        <sourcepath>
            <path location="companyproject-ejb/src/java"/>
            <path location="companyproject-models/src"/>
        </sourcepath>
        <classpath>
            <path refid="companyproject-models.module.classpath"/>
            <path refid="companyproject-ejb.module.classpath"/>
            <pathelement location="${companyproject-ejb.output.dir}"/>
        </classpath>
    </javadoc>
</target>

Some variations I have tried include: 我尝试过的一些变化包括:

<sourcefiles>
            <fileset dir="companyproject-ejb/src/java">
                <include name="**/*.java"/>
                <exclude name="**/*IntegrationTestWS*, **/*NhinInterfaceWS*"/>
            </fileset>
        </sourcefiles>

This errors with javadoc.exe CreateProcess error=87, The parameter is incorrect 此错误与javadoc.exe CreateProcess error=87, The parameter is incorrect

<sourcepath>
            <fileset dir="companyproject-ejb/src/java">
                <include name="**/*.java"/>
                <exclude name="**/*IntegrationTestWS*, **/*NhinInterfaceWS*"/>
            </fileset>
        </sourcepath>

Same error as sourcefiles, but has a lot of messages saying skipping <somefile> since it is no directory . 与sourcefiles相同的错误,但有很多消息说skipping <somefile> since it is no directory

I have tried similar variations using <files> instead of <fileset> . 我使用<files>而不是<fileset>尝试了类似的变体。

I think I am missing some basic understanding of how includes/excludes works. 我想我错过了一些关于如何包含/排除作品的基本理解。 Thank you for your help! 谢谢您的帮助!

AlexR didn't quite get it but came close. AlexR并没有得到它,但接近了。 I removed <sourcepath> and added 我删除了<sourcepath>并添加了

<fileset dir="./Companyproject-ejb/src/java/">
<include name="com/Company/project/webservices/*"/>
<exclude name="**/IntegrationTestWS*"/>
<exclude name="**/NhinInterfaceWS*"/>
</fileset>
<packageset dir="./Companyproject-models/src/">
    <include name="com/Company/project/models/**"/>
</packageset>

Having only a fileset led javadoc to complain that it couldn't find any packages. 只有一个文件集导致javadoc抱怨它找不到任何包。 Packageset behaves like a dirset, so it can't exclude single files, only directories. Packageset的行为类似于dirset,因此它不能排除单个文件,只能排除目录。 In this case I was able to define a packageset for one set of doco and a fileset for the restricted set and get around it. 在这种情况下,我能够为一组doco定义一个包集,并为限制集定义一个文件集并绕过它。

<fileset dir="src" defaultexcludes="yes">
  <include name="com/dummy/test/**"/>
  <exclude name="com/dummy/test/doc-files/**"/>
</fileset>

.................. ..................

I think that your mistake is the "sourcefiles" and "sourcepath" tags. 我认为你的错误是“sourcefiles”和“sourcepath”标签。 Try to remove them. 尝试删除它们。 For more information take a look here: http://ant.apache.org/manual/Tasks/javadoc.html 有关详细信息,请查看此处: http//ant.apache.org/manual/Tasks/javadoc.html

Good luck! 祝好运!

Just had the same problem and digged a bit into man javadoc to come to the conclusion that there is no solution, except for the workaround that happened to work in the OPs case. 刚刚遇到同样的问题,并在man javadoc挖掘了一点,得出的结论是没有解决方案,除了碰巧在OPs情况下工作的解决方法。 Yet I would like to document what I read from the docs. 但我想记录我从文档中读到的内容。

Ant's javadoc task is only a wrapper around Java's javadoc , so the latter's documentation applies. Ant的javadoc任务只是Java的javadoc的包装器,所以后者的文档适用。 In particular, javadoc seems to have two cleanly separated concepts of generating documentation: 特别是, javadoc似乎有两个完全分离的生成文档的概念:

  1. document packages 文件包
  2. document individual classes 记录个别课程

For (1) we specify package names like my.nice.package and -sourcepath to help javadoc find these packages. 对于(1),我们指定包名称,如my.nice.package和-sourcepath以帮助javadoc找到这些包。 Using ant, the names can be provided either as packagenames or as packageset where the latter converts path names to package names (slash to dot). 使用蚂蚁,名称可以被提供为packagenames或作为packageset其中后者转换路径名包名(斜线DOT)。

For (2) we specify file paths, possibly with wildcards. 对于(2),我们指定文件路径,可能使用通配符。 Then each individual file is documented. 然后记录每个单独的文件。 With ant, this is done via a nested fileset , which allows us to exclude files. 使用ant,这是通过嵌套fileset ,它允许我们排除文件。

Now it seems that two things don't play well together in javadoc . 现在看来,两个东西在javadoc并不能很好地结合在一起。

a) When documenting packages, there is no means to exclude individual files. a)记录包时,无法排除单个文件。

b) When documenting individual files, the packages are not documented, which leads to error messages about wrong references to package names when using {@link my.package} . b)记录单个文件时,不会记录包,这会导致在使用{@link my.package}时出现有关包名错误引用的错误消息。

Search for Documenting Both Packages and Classes in man javadoc , to see where I read this fror. man javadoc搜索文件包和类 ,以查看我在哪里阅读这篇文章。

This is a decade old problem , it seems :-( 这是十年之久的问题 ,似乎:-(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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