This page describes how wro.xml can be interpolated dynamically with some values in the runtime.


Sometimes it is useful to create wro.xml dynamically, like this:

<?xml version="1.0" encoding="UTF-8"?>
<groups xmlns=""
  xsi:schemaLocation=" wro.xsd">

  <group name="all">

Where ${theme} and ${externalUrl} are placeholders to be replaced at the runtime with some values.

In order to do this, wro4j exposes a factory method you can override to build the wro.xml model dynamically. Example:

public class MyWroManagerFactory
  extends ConfigurableWroManagerFactory {
  protected WroModelFactory newModelFactory(final ServletContext servletContext) {
    return new FallbackAwareXmlModelFactory() {
      protected InputStream getConfigResourceAsStream()
        throws IOException {
        return //compute the stream dynamically;

The implementation of getConfigResourceAsStream() method can call some sort of business logic responsible for dynamic wro.xml creation, not necessarily located inside the WEB-INF folder. An example of implementation could use a velocity template and VelocityEngine class provided by spring or any other technologies which you think suits best for building runtime templates.