Usage

The Velocity Tools Maven plugin contains mojos to work together with Velocity Tools.

Generate Velocity directives from JSP tag libraries.

JSP tag libraries can be wrapped into Velocity directives to use them into Velocity templates.

Create a new project and configure the plugin.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.velocity</groupId>
            <artifactId>maven-velocity-tools-plugin</artifactId>
            <version>2.1.0-SNAPSHOT</version>
            <configuration>
                <packageName>org.apache.velocity.tools.examples.displaytag</packageName>
                <prefix>display</prefix>
                <tld>META-INF/displaytag.tld</tld>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>displaytag</groupId>
                    <artifactId>displaytag</artifactId>
                    <version>1.2</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <id>directive-generation</id>
                    <goals>
                        <goal>taglib2directive</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

In this case we are wrapping DisplayTag. Notice the fact that DisplayTag is configured as a dependency of the plugin itself, because it uses it to reflect some properties from the original tag library.

Add a dependency to the taglib itself:

<dependencies>
    <dependency>
        <groupId>displaytag</groupId>
        <artifactId>displaytag</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.velocity</groupId>
        <artifactId>velocity</artifactId>
        <version>1.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.velocity</groupId>
        <artifactId>velocity-tools-view-jsp</artifactId>
        <version>2.1.0-SNAPSHOT</version>
    </dependency>
</dependencies>

To use it, in your velocity.properties file, add the list of generated directives this way:

userdirective=org.apache.velocity.tools.examples.displaytag.CaptionTagDirective,\
  org.apache.velocity.tools.examples.displaytag.ColumnTagDirective,\
  org.apache.velocity.tools.examples.displaytag.SetPropertyTagDirective,\
  org.apache.velocity.tools.examples.displaytag.TableFooterTagDirective,\
  org.apache.velocity.tools.examples.displaytag.TableTagDirective