Maven Archetype Plugin: Velocity Variable Substitutions Not Resolving


Let’s assume we have the following package.json in our archetype:-

  "name": "${rootArtifactId}",
  "private": true,
  "devDependencies": {

When creating a project from this archetype, the Velocity variable substitution for ${rootArtifactId} doesn’t resolve at all.


After reading Maven Archetype Plugin’s source code here and here, the Velocity variable substitutions are only performed on the following file extensions:-

        new String[]
                "java", "xml", "txt", "groovy", "cs", "mdo", "aj", "jsp", "gsp", 
                "vm", "html", "xhtml", "properties", ".classpath", ".project"

In another word, if we have these variables in JSON or JavaScript files, they will not resolved at all.

To fix this, define the needed file extensions in Maven Archetype Plugin configuration:-


Leave a Reply

Your email address will not be published.