Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tip for combining Maven and Diagram #212

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 84 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ This is necessary since the `<configuration>` element is used to configure more

Here's an example that shows how to set options, attributes and ignore partial AsciiDoc files (i.e., files that begin with an underscore).

[source,xml]
[source,xml,subs=attributes+]
.Maven site integration with Asciidoctor configuration
----
<plugin>
Expand Down Expand Up @@ -371,7 +371,7 @@ Here's an example that shows how to set options, attributes and ignore partial A
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>1.5.3</version>
<version>{release-version}</version>
</dependency>
</dependencies>
</plugin>
Expand Down Expand Up @@ -453,3 +453,85 @@ NOTE: If I can figure out a good way to setup a Ruby testing environment I'll do
...
</configuration>
-----

=== Using Asciidoctor Diagram

When using Asciidoctor Diagram from the maven plugin you need a couple of things to set the build pipeline up correctly.

First you need to enable Asciidoctor Diagram by adding the gem to the maven plugin and instructing it to look for the generated images in the target folder:

[source,xml,subs=attributes+]
----
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>{release-version}</version>
<configuration>
<attributes>
<graphvizdot>${dot.location}</graphvizdot> <!--1-->
<imagesdir>${project.build.directory}/generated-docs/images</imagesdir> <!--2-->
</attributes>
<doctype>book</doctype>
<gemPath>${project.build.directory}/gems-provided</gemPath> <!--3-->
<icons>font</icons>
<requires>
<require>asciidoctor-diagram</require> <!--4-->
</requires>
<sourceHighlighter>coderay</sourceHighlighter>
</configuration>
<dependencies>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj-pdf</artifactId>
<version>1.5.0-alpha.11</version>
</dependency>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj-diagram</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<version>${jruby.version}</version>
</dependency>
</dependencies>
</plugin>
----
<1> provide a location for the `dot` program used by e.g. graphviz
<2> set the source images folder to the place where the generated images end up
<3> configure the place where the gems are to be downloaded
<4> use the asciidoctor-diagram gem

You have now configured asciidoctor to look for images in the final folder where the images are copied to.
However when you do this, asciidoctor won't be able to find static images from your source folder, because they are copied by Maven at a later stage.
Therefore you should also instruct Maven to copy the static assets at an earlier phase during the build.
This is achieved by configuring the Maven Resources Plugin:

[source,xml]
----
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>initialize</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/generated-docs/images</outputDirectory>
<resources>
<resource>
<directory>src/main/asciidoc/images</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
----