vdubus/velocity-maven-plugin

ResourceManager unable to find resource in multi-module project

GoogleCodeExporter opened this issue · 3 comments

What steps will reproduce the problem?
1. Create a multi-module project where at least 2 modules use the Velocity 
plugin to process different templates.
2. Build the multi-module project (parent of the 2 modules).

What is the expected output? What do you see instead?
Projects should build correctly.
Instead, the first module succeeds, the second fails with the following error:
[ERROR] ResourceManager : unable to find resource 
'src/main/resources/sample.vm' in any resource loader.

What version of the product are you using? On what operating system?
Version 1.1.0 on Linux and Windows.

Please provide any additional information below.
This is caused by the use of a singleton Velocity engine, which can only be 
initialized once (while building the first module). Separate instances of 
VelocityEngine should be used instead (see 
http://velocity.apache.org/engine/releases/velocity-1.7/developer-guide.html#sep
arate).

The attached patch fixes this issue.

Original issue reported on code.google.com by fcres...@gmail.com on 4 Jan 2014 at 1:07

Attachments:

Fix the bug using attachments patch.

Hello,

do you have a configuration of a working example?

I'm facing an issue when trying to look for templates in the parent src folder.
It appends the file path I give to the relative basedir. So the folder does not exist obviously.

Here is my pseudo-file-structure:

project/
├── pom.xml
├── src/
│   ├── site/
│   │   ├── site.xml.vm
├── child1/
│   ├── pom.xml
└── child2/
│   ├── pom.xml

And here is my configuration in the root pom.xml, in the build/plugins section:

<plugin>
  <groupId>com.github.vdubus</groupId>
  <artifactId>velocity-maven-plugin</artifactId>
  <version>1.1.2</version>
  <executions>
    <execution>
      <id>Generate site descriptor</id>
      <phase>pre-site</phase>
      <goals>
        <goal>velocity</goal>
      </goals>
      <configuration>
        <removeExtension>.vm</removeExtension>
        <templateFiles>
          <directory>${maven.multiModuleProjectDirectory}/src/site</directory>
          <includes>
            <include>site.xml.vm</include>
          </includes>
        </templateFiles>
        <outputDirectory>${basedir}/src/site</outputDirectory>
      </configuration>
    </execution>
  </executions>
</plugin>

Removing ${maven.multiModuleProjectDirectory} makes it searching in the src/site relatively to basedir, and of course it neither does not exist.

Thank you in advance.
Regards,
Romain.

Sorry, I can't help you.
This version of the plugin was made to fix a few issue and make it compatible with the latest version of Velocity as the original plugin wasn't maintained anymore.
I don't work anymore for this company, nor with Velocity…