Open PowerStat opened 2 years ago
Thanks a lot for the thorough detail, this helps a lot!
This case is expected behaviour but can be improved and changed since we are working towards 3.x.x. The maven-plugin and site modules work differently than the Ruby cli because the nature is slightly different. Here the goal is converting sets of documents, so some common configurations are kept across them to simplify. Similar to how you have a single catalog for all images with a well-defined root path. But I admit this can be opinionated and it's normal to get confused.
You can see in the note below the Configuration example https://docs.asciidoctor.org/maven-tools/latest/site-integration/setup-and-configuration/#configuration. There it's mentioned all sources use the same base_dir 'src/site/asciidoc'.
Would be nice to fix this bug to allow asciidoc includes within subdirectory structures. Might be an upstream issue for the maven plugin.
The maven-plugin (that is the maven-plugin when used ouside maven-site-plugin) has an additional option close to what I think you expect called relativeBaseDir
https://docs.asciidoctor.org/maven-tools/latest/plugin/goals/process-asciidoc/#configuration-relativeBaseDir. I am thinking we could port that over to the site module(s).
Said that, the conversion runs once, so the log appearing twice is a surprise. I need to look further into that.
What is this issue about?
Description
Regarding the description at:
https://docs.asciidoctor.org/asciidoc/latest/directives/include/
"Include file resolution If the include directive is used in the primary (top-level) document, relative paths are resolved relative to the base directory. (The base directory defaults to the directory of the primary document and can be overridden from the CLI or API). If the include directive is used in a file that has itself been included, the path is resolved relative to the including (i.e., current) file."
I have found a bug regarding the above specification:
As an example please have a look at:
https://github.com/PowerStat/TemplateEngine/tree/master/src/
When I now add the following include to 06_runtime_view.adoc:
include::../../../test/java/de/powerstat/phplib/templateengine/test/TemplateEngineTests.java[tag=NonAppendBlock]
this results in the following output:So now I change the include to (one less dir level up):
include::../../test/java/de/powerstat/phplib/templateengine/test/TemplateEngineTests.java[tag=NonAppendBlock]
This results in the following output:
So now lets compare the error (path) from both outputs:
[INFO] asciidoctor: ERROR: architecture\06_runtime_view.adoc: line 51: include file not found: D:/work/eclipse/java/TemplateEngine/test/java/de/powerstat/phplib/templateengine/test/TemplateEngineTests.java
src is missing in the path[INFO] asciidoctor: ERROR: architecture\06_runtime_view.adoc: line 51: include file not found: D:/work/eclipse/java/TemplateEngine/src/site/test/java/de/powerstat/phplib/templateengine/test/TemplateEngineTests.java
site is to much in the pathWhat you can see is that in both cases the path is wrong! But the interesting thing is that this happens at two different positions in the output. So I assume that a two phase processing happens. That results to a bug, because in both phases you are working with different base directories!
In the first pass with:
projectBase/src/site/asciidoc/
(like set in sourceDirectory - the only correct value) In the second pass with:projectBase/src/site/asciidoc/architecture/
(Not sure if this is the config.adoc path or the one of the 06_runtime_view.adoc - wrong in both cases)Would be nice to fix this bug to allow asciidoc includes within subdirectory structures. Might be an upstream issue for the maven plugin.
The same happens under Windows as well as on MacOS (so I assume also on Linux).
My plugin configuration looks as follows:
Environment information