Mirror of Apache Velocity Engine

Overview

Title: Apache Velocity Engine

Apache Velocity

Welcome to Apache Velocity Engine! Apache Velocity is a general purpose template engine written in Java. For more information about Velocity, please look at the HTML documentation on the Velocity web site.

Here's a description of the top level directories:

velocity-engine-core/       The Velocity Engine core module
velocity-engine-examples/   Several simple examples
velocity-engine-scripting/  JSR-223 implementation for Velocity scripting
spring-velocity-support     Velocity Engine factory bean for Spring framework
src/                        Source for parent modules, mainly changelog

REQUIREMENTS

Apache Velocity 2.2 will run with any Java runtime engine v1.8 or greater.

Building from source requires Java development kit v1.8 or greater and Maven 3 (3.0.5+).

At compile time, Maven should fetch all engine needed dependencies, which are:

  • commons-lang v3.9
  • slf4j-api v1.7.30

plus the following ones, needed for the integrated tests:

  • slf4j-simple v1.7.30
  • junit v4.13
  • hsqldb v2.5.0
  • commons-io 2.8.0

At runtime, Velocity only needs:

  • commons-lang v3.9+
  • slf4j-api and an slf4j binding, v1.7.30+

BUILDING APACHE VELOCITY

In order to use the latest version of Apache Velocity, you may want to build it.

Building is easy. All components necessary to build are included or get downloaded from the internet during the build, except for the Java SDK and the Maven build tool. You can find details online on how to build Velocity.

IMPORTANT As the Apache Velocity build process wants to download a number of jars from the internet, you must be online when you are building for the first time.

To build Velocity's jar, just run maven using the command:

mvn

This will create a target/ directory containing the Velocity .jar file in each sub-module directory.

Be sure to update your classpath to include Velocity's .jar file, or when using a modern servlet container, put it in the WEB-INF/lib directory.

CUSTOMIZING THE PARSER

Since 2.2, it's possible to build a custom parser, to change some of the characters used by in the VTL syntax: *, @, $ and #.

Let's say you want to merge some templatized jQuery code full of $ characters, you can for instance build you own parser which will use the § character as references prefix instead of $.

TRYING THE EXAMPLES

After building Velocity, you can also build the examples that are included with the Velocity distribution. These examples show how to use Velocity in your Java applications.

For more information, please see the examples README in the velocity-engine-examples directory.


  • The Apache Velocity Team
Comments
  • Fixes VELOCITY-953

    Fixes VELOCITY-953

    VelocimacroProxy polutes context stack due to wrong handling of #break or exceptions.

    First PR failed testing. This one adds a guard due to MacroOverflowException already cleaning up the stack.

    opened by DoItWithASmile 2
  • New method to allow cache cleaning

    New method to allow cache cleaning

    Hi,

    I suggest to add a method in DuckType to clean the underlying cache held by the protected class Types. Actually, those caches could grow pretty big, depending of the number of classes.

    In our case, we have a special ClassLoader that allows us reloading classes during the runtime. Those classes will then be used in velocity templates, resulting in a memory leak (because the libraries are not reloaded within the same ClassLoader).

    Best regards, Cédric

    opened by ctabin 2
  • hsqldb 'jdk8' dependency classifier

    hsqldb 'jdk8' dependency classifier

    hsqldb 2.7.1 dependency without classifier has jdk 11 requirement.

    either:

    • upgrade project's min jdk version to 11 for tests
    • add jdk8 classifier to dependency (suggested option)
    opened by sultan 1
  • Bump spring-core from 5.3.4 to 5.3.19 in /spring-velocity-support

    Bump spring-core from 5.3.4 to 5.3.19 in /spring-velocity-support

    Bumps spring-core from 5.3.4 to 5.3.19.

    Release notes

    Sourced from spring-core's releases.

    v5.3.19

    :star: New Features

    • Remove DNS lookups during websocket connection initiation #28280
    • Add application/graphql+json Media type and MIME type constants #28271
    • Fix debug log for no matching acceptableTypes #28116
    • Provide support for post-processing a LocalValidatorFactoryBean's validator Configuration without requiring sub-classing #27956

    :lady_beetle: Bug Fixes

    • Improve documentation and matching algorithm in data binders #28333
    • NotWritablePropertyException when attempting to declaratively configure ClassLoader properties #28269
    • BeanPropertyRowMapper's support for direct column name matches is missing in DataClassRowMapper #28243
    • AbstractListenerReadPublisher does not call ServletOutputStream::isReady() when reading chunked data across network packets #28241
    • ResponseEntity objects are accumulated in ConcurrentReferenceHashMap #28232
    • Lambda proxy generation fix causes BeanNotOfRequiredTypeException #28209
    • CodeGenerationException thrown when using AnnotationMBeanExporter on JDK 17 #28138

    :hammer: Dependency Upgrades

    • Upgrade to Reactor 2020.0.18 #28329

    :heart: Contributors

    We'd like to thank all the contributors who worked on this release!

    v5.3.18

    :star: New Features

    • Restrict access to property paths on Class references #28261
    • Introduce cancel(boolean mayInterruptIfRunning) in ScheduledTask #28233

    :lady_beetle: Bug Fixes

    • Move off deprecated API in SessionTransactionData #28234

    :notebook_with_decorative_cover: Documentation

    • Introduce warnings in documentation of SerializationUtils #28246
    • Update copyright date in reference manual #28237
    • @Transactional test does not execute all JPA lifecycle callback methods #28228

    :heart: Contributors

    We'd like to thank all the contributors who worked on this release!

    ... (truncated)

    Commits
    • cedb587 Release v5.3.19
    • a7cf19c Improve documentation and matching algorithm in data binders
    • 0cf7f7b Polishing
    • 949c3d4 Align plain accessor check
    • 3b4ae7b TomcatHttpHandlerAdapter continues after 0 bytes
    • 8b39698 Upgrade to Reactor 2020.0.18
    • 6fad00e Ensure dynamic proxy with AOP introduction includes lambda interfaces
    • 5f6d8df Introduce isLambdaClass() as a public utility in ClassUtils
    • 35de7e1 Introduce initializer callback for Bean Validation Configuration
    • 10e979e Polishing
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Bump spring-core from 5.3.4 to 5.3.18 in /spring-velocity-support

    Bump spring-core from 5.3.4 to 5.3.18 in /spring-velocity-support

    Bumps spring-core from 5.3.4 to 5.3.18.

    Release notes

    Sourced from spring-core's releases.

    v5.3.18

    :star: New Features

    • Restrict access to property paths on Class references #28261
    • Introduce cancel(boolean mayInterruptIfRunning) in ScheduledTask #28233

    :lady_beetle: Bug Fixes

    • Move off deprecated API in SessionTransactionData #28234

    :notebook_with_decorative_cover: Documentation

    • Introduce warnings in documentation of SerializationUtils #28246
    • Update copyright date in reference manual #28237
    • @Transactional test does not execute all JPA lifecycle callback methods #28228

    :heart: Contributors

    We'd like to thank all the contributors who worked on this release!

    v5.3.17

    :star: New Features

    • Using DataClassRowMapper causes "No property found for column" debug messages in logs #28179
    • Improve diagnostics in SpEL for large array creation #28145
    • Support custom HTTP status in client-side REST testing support #28105
    • AsyncRestTemplate logging too verbose #28049

    :lady_beetle: Bug Fixes

    • java.lang.NoClassDefFoundError: org/springframework/cglib/beans/BeanMapEmitter #28110
    • CronExpression fails to calculate properly next execution when running on the day of winter daylight saving time #28095
    • Private init/destroy method may be invoked twice #28083
    • MappingJacksonValue and Jackson2CodecSupport#registerObjectMappersForType do not work together #28045
    • SpEL fails to recover from error during MIXED mode compilation #28043
    • When returning a ResponseEntity with a Flux while the function is suspended, it fails to encode the body #27809

    :notebook_with_decorative_cover: Documentation

    • Improve documentation for @EnabledIf and @DisabledIf test support #28157
    • Links to Spring Security are broken in the reference guide #28135
    • Document that transaction rollback rules may result in unintentional matches #28125
    • Improve documentation for TestContext events #27757
    • Clarify behavior for generics support in BeanUtils.copyProperties #27259

    :hammer: Dependency Upgrades

    ... (truncated)

    Commits
    • 707a24c Release v5.3.18
    • 002546b Refine PropertyDescriptor filtering
    • 1627f57 Disable flaky integration tests for now
    • 3811cd4 Introduce warnings in documentation of SerializationUtils
    • d927e37 Add "Testing ORM entity lifecycle callbacks" note to Testing chapter
    • 1d302bf Introduce tests for gh-28228
    • 4b150fd Update copyright date in reference manual
    • 3a6016d Merge pull request #28238 from izeye
    • 135506f Update copyright year of EvaluationTests
    • cb36ca3 Upgrade to ASM master
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • add the ability to override defaultEncoding

    add the ability to override defaultEncoding

    the defaultEncoding used by runtime instance is not overridable. currently it is loaded on initialization of RuntimeInstance from the default configuration object without taking overridingProperties into account.

    by this change, after merging overridingProperties into RuntimeInstance#configuration the defaultEncoding gets reinitialized.

    opened by gndrm 1
  • core: update the version of commons-io

    core: update the version of commons-io

    There is a vulnerability CVSS V2: 7.1/AV:N/AC:M/Au:N/C:N/I:N/A:C fixed by commit to commons-io which is shaded into the final jar for velocity. Upgrading version to remove vulnerability.

    opened by daniel-ranallo 1
  • don't leak classes via Stop.STOP_ALL stack trace

    don't leak classes via Stop.STOP_ALL stack trace

    this prevented garbage-collecting classloaders that accidentally happened to be in the stack trace when Stop class was first accessed

    This prevents plugin unloading in IntelliJ: https://youtrack.jetbrains.com/issue/IDEA-240449

    opened by donnerpeter 1
  • 1.7.x

    1.7.x

    I'd like to change the pom.xml so it depends on Apache commons collections JAR version 3.2.2 instead of 3.2.1. The new version is a hardened JAR that addresses the serialization vulnerability reported in Nov 2015: https://www.us-cert.gov/ncas/current-activity/2015/11/13/Apache-Commons-Collections-Java-Library-Vulnerability

    opened by duffymo 1
  • Bump spring-core from 5.3.4 to 5.3.20 in /spring-velocity-support

    Bump spring-core from 5.3.4 to 5.3.20 in /spring-velocity-support

    Bumps spring-core from 5.3.4 to 5.3.20.

    Release notes

    Sourced from spring-core's releases.

    v5.3.20

    :star: New Features

    • Refine CachedIntrospectionResults property introspection #28445
    • Improve tests and Javadoc on binding to a property of type javax.servlet.Part #27830
    • WritableResource doesn't have parity with Resource in @Value etc. [SPR-10656] #15284

    :lady_beetle: Bug Fixes

    • Ignore invalid STOMP frame #28443
    • @ModelAttribute name attribute is not supported in WebFlux #28423
    • Fix BindingResult error when ModelAttribute has custom name in WebFlux #28422
    • Request body deserialization failures are not captured by exception handlers in WebFlux #28155

    :notebook_with_decorative_cover: Documentation

    • Remove Log4J initialization from package-info.java in spring-web #28420
    • Remove Log4J configurer from package-info.java in spring-core #28411
    • Fix github issue reference in RequestMappingHandlerMapping #28372
    • Add Javadoc since tags for GraphQL constants #28369
    • Fix method reference in Kotlin documentation #28340

    :hammer: Dependency Upgrades

    • Upgrade to ASM 9.3 #28390
    • Upgrade to Reactor 2020.0.19 #28437

    :heart: Contributors

    We'd like to thank all the contributors who worked on this release!

    v5.3.19

    :star: New Features

    • Remove DNS lookups during websocket connection initiation #28280
    • Add application/graphql+json Media type and MIME type constants #28271
    • Fix debug log for no matching acceptableTypes #28116
    • Provide support for post-processing a LocalValidatorFactoryBean's validator Configuration without requiring sub-classing #27956

    :lady_beetle: Bug Fixes

    ... (truncated)

    Commits
    • e0f56e7 Release v5.3.20
    • 83186b6 Refine CachedIntrospectionResults property introspection
    • dc2947c Ignore invalid connect frame
    • e4ec376 Disabling Undertow server in CoroutinesIntegrationTests
    • c81e11d Polishing
    • de6180b Upgrade to Reactor 2020.0.19
    • 1c10cdd Update copyright dates
    • 941b92c Make inner classes static when feasible
    • e26d883 Stop referring to features as Java 6/7 features where unnecessary
    • a1c7380 Add test for value attribute in @​ModelAttribute in WebFlux
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • refactor the velocity with a more scalable api and spi interfaces

    refactor the velocity with a more scalable api and spi interfaces

    I want to refactor the velocity with a more scalable API (for Users) and SPI (for Developers), but I don't know whether it's needed, So I created this pr for ensure it (Please tell me if you need otherwise please close this pr, Thank you! ).

    The target is:

    1. compile the template(.vm) to a java class(.java), also provide a interpreter like now.
    2. the template#render will compile the generated java code to a java class and execute it.

    The sample usage For User:

    Template template = VelocityEngine.getTemplate(name, locale, encoding);
    template.render(context, writer);
    

    Sample Implementation is:

    Template getTemplate(String name, Locale locale, String encoding) {
      // 0. cache
      Resource r = cache.get(name);
      // 1. load (the loader maybe is ClasspathLoader, FileLoader, JarLoader... )
      r = loader.load(name, locale, encoding);
      // 2. read a .vm file to string with encoding
      String source = r.getSource();
      // 3. convert xxs characters
      source = converter.convert(name, source);
      // 4. compile
      Class<?> templateClass = compiler.compile(source); // maybe a CompiledTemplate or a InterpretedTemplate
      // 5. create template instance
      return templateClass.getConstructor().newInstance();
    }
    
    opened by xiaoma20082008 2
  • Provide a flag to ignore exception when template generator encounters…

    Provide a flag to ignore exception when template generator encounters…

    … null to render in StrictMode. This is particularly useful in our upcoming change where in we want to turn StrictMode on but fear we might encounter a lot of such errors in prod.

    opened by yaverhussain 4
Owner
The Apache Software Foundation
The Apache Software Foundation
This is a Velocity plugin that makes it possible to host a modern forge server behind a Velocity proxy!

Ambassador This is a Velocity plugin that makes it possible to host a modern forge server behind a Velocity proxy! Unlike other solutions, this plugin

Adrian Bergqvist 31 Dec 28, 2022
Drools is a rule engine, DMN engine and complex event processing (CEP) engine for Java.

An open source rule engine, DMN engine and complex event processing (CEP) engine for Java™ and the JVM Platform. Drools is a business rule management

KIE (Drools, OptaPlanner and jBPM) 4.9k Dec 31, 2022
LimboAuth - Minecraft Auth System for Velocity proxy built in virtual server (Limbo).

LimboAuth Auth System built in virtual server (Limbo). MC-Market SpigotMC.org Описание и обсуждение на русском языке (spigotmc.ru) Описание и обсужден

Elytrium 89 Jan 4, 2023
Velocity global chat/discord bridge

VelocityDiscord Velocity global chat/discord bridge Default config generated on startup: # Don't change this config_version="1" [discord] # Bot token

Foo 8 Dec 18, 2022
MiniMessage Component-based Placeholders for PaperMC and Velocity platforms

MiniMessage Component-based Placeholders for PaperMC and Velocity platforms

null 10 Dec 28, 2022
Protect your Spigot server against IP forwarding exploits, as well as blocking unknown BungeeCord and/or Velocity proxies.

Sentey Protect your Spigot server against IP forwarding exploits, as well as blocking unknown BungeeCord and/or Velocity proxies. But firewalls are a

ComuGamers Network 18 Dec 28, 2022
Make the Velocity proxy run commands based on backend input.

Command Sync Server This plugin allows the Velocity proxy to run commands based on backend input. Purpose The purpose of this is to allow easy access

Wind Development 3 May 23, 2022
Plugin for Spigot, PaperMC, BungeeCord and Velocity to create custom MOTDs, playercount message and playercount hover with priorities and conditions.

AdvancedServerList AdvancedServerList is a server and proxy plugin that allows you to create custom MOTDs and more in your server list with priority a

Andre_601 19 Dec 14, 2022
A MOTD plugin for Velocity that caches network packets. This helps it be the fastest one of the MOTD plugins.

FastMOTD A MOTD plugin for Velocity that catches network packets. This helps it be the fastest one of the MOTD plugins. Test server: ely.su Features F

Elytrium 19 Dec 24, 2022
I had too much coffee and decided to mirror my actions by writing too many programs in Java.

Raging Coffee Table of Contents Description Running the Programs Extra Dependencies Roadmap Further Reading Known Issues Resources Contributions Descr

Thoroughfare by the Brooks 20 Dec 15, 2022
A Java-based template project for the FastJ Game Engine.

FastJ Java Template Program Requirements Java 16 JDK Basic understanding of Java Initial Setup Download the Template You have a few options for gettin

Andrew Dey 13 May 15, 2022
Realtime Data Processing and Search Engine Implementation.

Mutad The name Mutad is a reverse spelling of datum. Overview An implementation of a real-time data platform/search engine based on various technology

Shingo OKAWA 14 Aug 4, 2022
🕊️ The world's most advanced open source instant messaging engine for 100K~10M concurrent users https://turms-im.github.io/docs

简体中文 What is Turms Turms is the most advanced open-source instant messaging engine for 100K~10M concurrent users in the world. Please refer to Turms D

null 1.2k Dec 27, 2022
Sceneform React Native AR Component using ARCore and Google Filament as 3D engine. This the Sceneform Maintained Component for React Native

Discord Server Join us on Discord if you need a hand or just want to talk about Sceneform and AR. Features Remote and local assets Augmented Faces Clo

SceneView Open Community 42 Dec 17, 2022
Google App Engine Standard Environment Source Code for Java 8 and Java11

Google App Engine Standard Environment Source Code for Java 8 and Java11. This is a repository that contains the Java Source Code for Google App Engin

Google Cloud Platform 167 Jan 2, 2023
Rivr is a lightweight open-source dialogue engine enabling Java developers to easily create enterprise-grade VoiceXML applications.

Overview Rivr is a lightweight open-source dialogue engine enabling Java developers to easily create enterprise-grade VoiceXML applications. Read our

Nu Echo Inc. 57 Jun 27, 2022
Multi-OS Engine: Create iOS Apps in Java (or Kotlin ... etc.)

Multi-OS Engine Overview Multi-OS Engine provides a Java runtime and Java interfaces to iOS platform API to develop native iOS applications with nativ

Multi-OS Engine 561 Dec 22, 2022
The simple, stupid rules engine for Java

Easy Rules The simple, stupid rules engine for Java™ Project status As of December 2020, Easy Rules is in maintenance mode. This means only bug fixes

Jeasy 4.2k Jan 5, 2023
Cadence is a distributed, scalable, durable, and highly available orchestration engine to execute asynchronous long-running business logic in a scalable and resilient way.

Cadence This repo contains the source code of the Cadence server and other tooling including CLI, schema tools, bench and canary. You can implement yo

Uber Open Source 6.5k Jan 4, 2023