Maven archetype creation: conflicts between jsp and velocity templates

When creating a maven artefact, i came up with a conflict between velocity template engine and some definition i had in some jsp.

issue was reported when calling mvn:generate with the following error message

[ERROR] ResourceManager.getResource() parse exception
[ERROR] org.apache.velocity.exception.ParseErrorException: Encountered ” }\” />\nPortlet!\n” at line 6, column 47 of archetype-resources/src/main/webapp/WEB-INF/jsp/view.jsp
Was expecting one of:
“}” …
<DOT> …

The issue came from the way I told maven about the files to bundle along with the template:

in my archetype-metadata.xml I had

        <fileSet filtered=”true” packaged=”false”>
<directory>src/main/webapp</directory>
</fileSet>

which caused jsp to be processed by velocity.

What I did is replace the previous configuration with the following:

<fileSet filtered=”true” packaged=”false”>
<directory>src/main/webapp</directory>
<excludes>
                <exclude>**/*.jsp</exclude>
</excludes>
</fileSet>

<fileSet filtered=”false” packaged=”false”>
<directory>src/main/webapp/</directory>
<includes>
<include>**/*.jsp</include>
</includes>
</fileSet>

forcing maven to prevent velocity parsing for my jsp when generating the project.

Leave a comment