Search code examples
mavenvelocitymaven-archetype

What exactly is "filtered" in archetype-metadata.xml


The maven-documentation is not very helpful:

Filesets can be filtered, which means the selected files will be used as Velocity templates. They can be non-filtered, which means the selected files will be copied without modification.

So let's take the underneath code. I know that the selected files will be used as Velocity templates and therefore they can be manipulated. How can I manipulate this fileset and how can I use Velocity templates?

<fileSets>
    <fileSet filtered="true" packaged="true">
      <directory>src/test/java</directory>
      <includes>
        <include>**/*.java</include>
      </includes>
      <excludes>
        <exclude>AllTest.java</exclude>
      </excludes>
    </fileSet>
  </fileSets>

Solution

  • As you said, if you set filtered to true, then the Velocity engine takes the files and does all the Velocity replacements, including replacing variables given in the $ syntax and evaluating Velocity loops.

    The variable values are the properties set in the POM.