2016-06-16 11 views
3

私はAsciiDocを使用しているユーザーガイドを持っていますが、時間がかかりませんでしたが、非常に美しいです。Maven変数をasciidoctor-maven-pluginに渡すには?

AsciiDocプラグインは素晴らしいです。だから私はMavenの最終的な名前をユーザガイドに渡したいと思っています。

質問:それを行う方法?

<finalName>${project.artifactId}-${project.version}-${version.state}-r${buildNumber}</finalName> 

マイasciidoctor-maven-plugin構成は次のとおり

<plugin> 
    <groupId>org.asciidoctor</groupId> 
    <artifactId>asciidoctor-maven-plugin</artifactId> 
    <version>${asciidoctor.maven.plugin.version}</version> 
    <dependencies> 
     <dependency> 
      <groupId>org.asciidoctor</groupId> 
      <artifactId>asciidoctorj-pdf</artifactId> 
      <version>${asciidoctorj.pdf.version}</version> 
     </dependency> 
     <!-- Comment this section to use the default jruby artifact provided by the plugin --> 
     <dependency> 
      <groupId>org.jruby</groupId> 
      <artifactId>jruby-complete</artifactId> 
      <version>${jruby.version}</version> 
     </dependency> 
     <!-- Comment this section to use the default AsciidoctorJ artifact provided by the plugin --> 
     <dependency> 
      <groupId>org.asciidoctor</groupId> 
      <artifactId>asciidoctorj</artifactId> 
      <version>${asciidoctorj.version}</version> 
     </dependency> 
    </dependencies> 
    <configuration> 
     <sourceDirectory>src/docs/asciidoc</sourceDirectory> 
     <sourceDocumentName>manual.adoc</sourceDocumentName> 
     <!-- Attributes common to all output formats --> 
     <attributes> 
      <sourcedir>${project.build.sourceDirectory}</sourcedir> 
     </attributes> 
    </configuration> 
    <executions> 
     <execution> 
      <id>generate-pdf-doc</id> 
      <phase>generate-resources</phase> 
      <goals> 
       <goal>process-asciidoc</goal> 
      </goals> 
      <configuration> 
       <backend>pdf</backend> 
       <!-- Since 1.5.0-alpha.9 PDF back-end can use 'rouge' as well as 'coderay' 
      source highlighting --> 
       <sourceHighlighter>rouge</sourceHighlighter> 
       <attributes> 
        <icons>font</icons> 
        <pagenums/> 
        <toc/> 
        <idprefix/> 
        <idseparator>-</idseparator> 
       </attributes> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

答えて

7

official user guideカバーそのPassing POM propertiesセクションにおいて、この場合:

AsciidoctorプロセッサにPOMで定義されたプロパティを通過することが可能です。これは、例えば生成された文書にPOM案件のバージョン番号を含める場合に便利です。

これは、configurationattributesセクションにカスタムAsciiDocプロパティを作成することによって行われます。 AsciiDocプロパティ値は通常のMavenの方法で定義されています:${myMavenProperty}

<attributes> 
    <project-version>${project.version}</project-version> 
</attributes> 

カスタムAsciiDocプロパティは、このように文書で使用することができます。したがって

The latest version of the project is {project-version}. 

、あなたはそれ故に、既存のconfigurationに次を適用することができます。

<configuration> 
    <sourceDirectory>src/docs/asciidoc</sourceDirectory> 
    <sourceDocumentName>manual.adoc</sourceDocumentName> 
    <!-- Attributes common to all output formats --> 
    <attributes> 
     <sourcedir>${project.build.sourceDirectory}</sourcedir> 
     <!-- the new property --> 
     <final-name>${project.build.finalName}</final-name> 
    </attributes> 
</configuration> 
+0

ASCII Docのユーザーガイドはとても良いので、私はそれを見つけられなかったことを恥知らずに感じます。ありがとう@A。 Di Matteo。 – Xelian