asciidoctor / asciidoctor-maven-plugin

A Maven plugin that uses Asciidoctor via JRuby to process AsciiDoc source files within the project.
http://asciidoctor.org
Apache License 2.0
317 stars 122 forks source link

Resource copy in multi-module does not work #838

Closed jjoslet closed 4 months ago

jjoslet commented 4 months ago

What is this issue about?

Description

Considering the following multi-module maven project:

The module-doc\pom.xml contains the plugin execution with the following resources:

<resources>
    <resource>
        <directory>src/docs/asciidoc/images/</directory>
        <targetPath>images/</targetPath>
        <includes>
            <include>*.png</include>
        </includes>
    </resource>
</resources>

The sample.png image is not copied in the output directory as expected.

Environment information

abelsromero commented 4 months ago

Thanks!

I was able to find an issue in https://github.com/asciidoctor/asciidoctor-maven-plugin/blob/41a3fce15e9715eb375c883306f2bef326d4223f/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/process/CopyResourcesProcessor.java#L123-L126. new File() takes the working directory as root, so when running from the parent module it's expecting resources to be in that parent. We simply need to pass the project baseDir from the Mojo. I can't but laugh :smile: at those small un-noticed issues lingering for a long time. Happy to assist if you want to contribute it btw.

In the meantime, you can add it to the configuration.

   <directory>${project.basedir}/src/docs/asciidoc/images/</directory>

PS: not sure what you is the goal, but all non-AciiDoc sources are copied by default. There's no need to specify the resources bloc if you have some images.

schastlivcev commented 4 months ago

Hi, I've tried to fix it in https://github.com/asciidoctor/asciidoctor-maven-plugin/pull/841. Can you please see if I updated the tests correctly?