如何在javadoc概述页面中访问maven项目版本?

时间:2015-12-23 11:47:55

标签: maven pdf maven-javadoc-plugin

我正在使用PDFDocletmaven-javadoc-plugin,我现在已经走了很长一段路。我的maven和javadoc配置几乎已经足够好但我现在的问题是我无法解决如何将项目版本号推送到PDF标题页面的问题。

在您通过告诉我使用maven的<resource>过滤来回答我的问题之前,让我概述一下为什么它不起作用。

通过从src文件夹中的某个位置获取原始文件进行过滤,执行变量替换并将输出放在target文件夹中。

Javadoc通过阅读src/main/javasrc/main/javadoc中的文件以及将结果输出到target的AFAIK来工作。这意味着过滤对于Javadoc来说是无用的,因为它不会从target读取任何内容

我的结果显示javadoc评论中的任何maven变量都没有被替换。

我可以使用什么技巧将这些变量替换为javadoc?

解决方案无法在site:site任务之后过滤javadoc输出,除非资源过滤适用于PDF。

这是配置,FWIW:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.10.3</version>
    <configuration>
      <show>package</show>
      <docfilessubdirs>true</docfilessubdirs>
      <tags>
        <tag>
          <name>pdfInclude</name>
          <placement>X</placement>
          <head></head>
        </tag>
      </tags>
    </configuration>
    <reportSets>
      <reportSet>
        <id>PDF</id>
        <reports>
          <report>javadoc</report>
        </reports>
        <configuration>
          <name>PDF</name>
          <description>PDF doc</description>
          <destDir>pdf</destDir>
          <doclet>com.tarsec.javadoc.pdfdoclet.PDFDoclet</doclet>
          <docletPath>${basedir}/pdfdoclet/pdfdoclet-1.0.3-all.jar</docletPath>
          <useStandardDocletOptions>false</useStandardDocletOptions>
          <additionalparam>-pdf my_tech_doc-${project.version}.pdf
            -config ${basedir}/pdfdoclet/pdfdoclet.properties</additionalparam>
        </configuration>
      </reportSet>
    </reportSets>
  </plugin>

pdfdoclet.properties

    # http://pdfdoclet.sourceforge.net/configuration.html
    #
    #Lets the doclet print additional output in the console and to a logfile.
    debug=true 
    #Print "Author" tags
    author=false  
    #Print "Version" tags
    version=true
    #Print "since" tags
    tag.since=true
    #Create summary tables
    summary.table=false
    #Create hyperlinks
    create.links=true
    #Encrypt the PDF file
    encrypted=false
    #Allow printing of the PDF file
    allow.printing=true 
    #Create a bookmark frame
    create.frame=true
    #Print a title page
    api.title.page=true
    api.copyright=None
    api.author=Hansruedi
    #Enables the tag-based filter
    filter=true
    filter.tags=pdfInclude
    font.text.name=resources/arial.ttf
    page.orientation=portrait

PDFDoclet - 特定api.*属性应该会将标题页作为PDF的第一页,但它不起作用。如果有一个我在这里错过的技巧并且我可以制作那个标题页,那么这也可能允许以某种方式解决这个问题。

1 个答案:

答案 0 :(得分:0)

我意识到我可以使用maven <resources>功能进行快速而肮脏的黑客攻击:

  <resource>
    <directory>${basedir}/src/main/resources</directory>
    <targetPath>${basedir}/src/main/javadoc</targetPath>
    <filtering>true</filtering>
    <includes>
      <include>**/overview.html</include>
    </includes>
  </resource>

这会复制我的overview.html并过滤它,并将其输出到javadoc源目录。

虽然使用svn我可以将ignore列表添加到..... "aliases": [], "minimum-stability": "stable", "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { "php": ">=5.3.3" }, ..... 列表中,但过滤后的版本可能会在版本控制下意外结束。