Re: How to use the asciidoctor-maven-plugin to compile a separate jar package for asciidoc

Posted by abelsromero on
URL: https://discuss.asciidoctor.org/How-to-use-the-asciidoctor-maven-plugin-to-compile-a-separate-jar-package-for-asciidoc-tp6081p6082.html

Hi,

I understand you need to generate 2 different jars with totally separated content all at once. If so, that's one case in which maven does not shine, but it's possible.

EDITED: I found a much better alternative solution, to I am removing my previous post. Apologies.

First, you need to set up a new jar with a custom classifier, check this: https://maven.apache.org/plugins/maven-jar-plugin/examples/attached-jar.html. Similarly to how you can generate an artifact-sources.jar, artifact-javadoc.jar, etc. you can create a custom "artifact-asciidocs.jar".
The tricky part is that you need to align the </outputDirectory> from asciidoctor-maven-plugin with <classesDirectory> in maven-jar-plugin. I'd recommend to use a property, for instance I wrote an example pointing both to `${build.outputDirectory}/my-generated-docs`.

One consideration to have in mind is adding the output format to the classifier. Just in case you want to generate a jar with html and another with pdf for example, and be able to diferentiate them.