vdubus/velocity-maven-plugin

Includes don't work in multi module projects when using relative paths

GoogleCodeExporter opened this issue · 7 comments

What steps will reproduce the problem?
1. Use an include or parse statement in your processed file. Let file A include 
another file B in the same directory. B is included via a relative path, say 
src/main/vm/...
2. Use the velocity-maven-plugin as part of your build in a Maven project X to 
process file A.
3. Be sure this works when building project X
4. Build the parent project of X, say Y

What is the expected output? What do you see instead?
Expected: it doen't matter if you build X or Y, in both cases the output file 
is the same.
Instead the process fails when building Y.

What version of the product are you using? On what operating system?
1.0.0 or 1.0.1-SNAPSHOT revision 37.

Please provide any additional information below.
The problem is how paths are handled. In step 3 velocity works in the directory 
of X, in step 4. this is the directory of Y. Relative paths in the include 
statements which work in step 3. fail in step 4.

I attached a patch file which may this clearer. The patch sets the velocity 
property Velocity.FILE_RESOURCE_LOADER_PATH to the basedir of the maven 
project. This is always the directory of project X. The method 
getProjectRelativeDirectory() and the variable relPath aren't necessary anymore.

Original issue reported on code.google.com by bjoern.w...@gmail.com on 21 Mar 2012 at 4:36

Attachments:

I aslo have the same problem: I'd like to share a single template file across 
multiple modules, but this plugin does not allow relative path so it's 
impossible to use a template such as "../results.html".

I don't see any benefit from this constraint.

Original comment by mickael.istria on 29 Mar 2013 at 2:05

IMO, there 3 lines could be removed: 
http://code.google.com/p/velocity-maven-plugin/source/browse/tags/velocity-maven
-plugin-1.0.1/src/main/java/com/googlecode/VelocityMojo.java#90

Original comment by mickael.istria on 29 Mar 2013 at 2:14

How about commiting the fix?

Original comment by ame...@gmail.com on 19 Jun 2013 at 7:14

I've committed the patch as well as the removal of the exception (was on line 
3) throwing.

Original comment by javamonk...@gmail.com on 26 Dec 2013 at 9:31

  • Changed state: Fixed
I've applied the patch, and the project still fails when attached to a goal of 
a parent project.

I get:

[ERROR] Failed to execute goal 
com.googlecode.velocity-maven-plugin:velocity-maven-plugin:1.1.0-SNAPSHOT:veloci
ty () on project one: The parameters 'templateFiles' for goal 
com.googlecode.velocity-maven-plugin:velocity-maven-plugin:1.1.0-SNAPSHOT:veloci
ty are missing or invalid -> [Help 1]

I'm not quite sure why.

Original comment by javamonk...@gmail.com on 26 Dec 2013 at 10:21

  • Changed title: Includes don't work in multi module projects when using relative paths

Original comment by javamonk...@gmail.com on 26 Dec 2013 at 10:22

  • Changed state: Accepted
I've applied your patch as well as some other refactoring. I'm not convinced 
that it fixes your use case or not though, there is no definite unit test. I'm 
closing this issue for now, if this does not fix it please submit another patch 
or additional information.

The changes have been released to v1.1.0.

Original comment by javamonk...@gmail.com on 27 Dec 2013 at 5:00

  • Changed state: Fixed