asciidoctor/asciidoctor-maven-plugin

Resource copy in multi-module does not work

jjoslet opened this issue ยท 2 comments

What is this issue about?

  • Bug report ๐Ÿชฒ
  • Feature request ๐ŸŽ
  • Question โ“ Consider dropping it first in the Project Chat

Description

Considering the following multi-module maven project:

  • pom.xml
  • module-doc\
    • pom.xml
    • src/docs/asciidoc/
      • index.adoc
      • images/sample.png

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

  • asciidoctor-maven-plugin version: 3.0.0
  • asciidoctorj version: 2.5.11
  • Apache Maven 3.9.3
  • Java version: 17.0.8.1
  • Windows 11

Thanks!

I was able to find an issue in

.filter(resource -> new File(resource.getDirectory()).exists())
.forEach(resource -> {
DirectoryScanner directoryScanner = new DirectoryScanner();
directoryScanner.setBasedir(resource.getDirectory());
. 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 ๐Ÿ˜„ 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.

Hi, I've tried to fix it in #841. Can you please see if I updated the tests correctly?