A ready-configured Apache Velocity engine as an injectable component, so a plugin can render a template without setting up Velocity itself.
Maintained, quietly. It is a thin wrapper over Velocity; most changes here are Velocity upgrades.
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-velocity</artifactId>
</dependency>Check the badge above for the current version.
@Inject
VelocityComponent velocityComponent;
VelocityContext context = new VelocityContext();
Template template = velocityComponent.getEngine().getTemplate( "path/to/template.vm" );
StringWriter writer = new StringWriter();
template.merge( context, writer );The engine starts with these defaults, which a VelocityComponentConfigurator can change or replace:
- templates are looked up on the classpath first, then as files (the file loader path is empty, so a relative name resolves against the working directory and an absolute path works as is);
#includeand#parseresolve relative to the including template (IncludeRelativePath);- invalid references are not logged, and neither is each template that is found;
- a
#macrodefined inline replaces a global one with the same name (velocimacro.inline.replace_global); parser.space_gobblingisbc.
The default configuration is meant to be customised: provide a VelocityComponentConfigurator
implementation, whose configure(Properties) receives these defaults before the engine starts, and it will be
picked up. It is optional. The engine is created once and shared. See the
Velocity configuration reference for what
can be set.
Java 8 or later. Building the project needs Maven 3.9.0 or later.
Conventions for contributors and agents are in AGENTS.md; see also
CONTRIBUTING.md. In short:
mvn verify builds, and run mvn spotless:apply before pushing or CI will fail on formatting.
Please report security vulnerabilities privately — see SECURITY.md, not a public issue.