asciidoctor-maven-plugin icon indicating copy to clipboard operation
asciidoctor-maven-plugin copied to clipboard

Adjust the Doxia Site components to be able to generate diagram output into the correct directories

Open chrisdutz opened this issue 7 years ago • 5 comments

When using the diagram plugin to generate diagrams contained inside asciidoctor files, all output is generated into the root modules site directory. This breaks all the sub-modules.

The MavenProject property seems to be set to the instance of the root project and isn't updated for child modules.

I had to fork and patch AsciidoctorDoxiaParser to get the current base dir from the sinks rendering context, but I'm not quite happy with this.

It would be cool if there was some way to provide the imagesoutdir in a way that it produces a usable site for every sub-module.

My modification now allows this:

            <imagesoutdir>@{project.basedir}/target/site/img</imagesoutdir>

And it sets the value correctly, but this is nothing but a bad hack ... I would prefer a clean solution.

Do you have any ideas? I would be more than happy to help fixing this, I would however need some pointers to how to do this nicely.

chrisdutz avatar May 30 '18 14:05 chrisdutz

I am curious on how to did the change...feel free to share it or send a PR that we can use as prototype.

abelsromero avatar May 30 '18 14:05 abelsromero

Well this hack is so bad that I don't really want to put it out into the wild ;-) ... I would much more prefer to make a real solution.

The main problem with it is that it's a patch of the asciidoc tool to set properties of a plugin ... it shouldn't be that way around, but the other way. So if the diagram plugin for asciidoc is present then it adds config options.

Eventually I'll contact the guys on the maven mailinglist to address this issue correctly. But the main problem is that the configuration is always taken from where the site definition comes from, which is usually the root ... So I replaced "${some property}" with "@{project.basedir}" and replace that in the asciidoc-maven-plugin with something I fetch from the doxia sink.

chrisdutz avatar Jun 02 '18 13:06 chrisdutz

The main problem with it is that it's a patch of the asciidoc tool to set properties of a plugin

That's pretty much what the plugin does; iterate over source documents and adjust the options/attributes for each one of them.

So I replaced "${some property}" with "@{project.basedir}" and replace that in the asciidoc-maven-plugin with something I fetch from the doxia sink

It really sounds ok so far.

Thing is I was proposing to start by your idea, because I wont' be able to check this this week :/

abelsromero avatar Jun 03 '18 18:06 abelsromero

Done ... see: https://github.com/asciidoctor/asciidoctor-maven-plugin/pull/350

chrisdutz avatar Jun 05 '18 19:06 chrisdutz

Was able to make the hack a little cleaner, by updating to Doxia 1.8, which provides a getRelativeBaseDir method. Will now replace any occurrence of "@{project.basedir}" in any attribute value with the current modules base dir absolute path.

chrisdutz avatar Jun 05 '18 19:06 chrisdutz