first implementation of scripting support (using groovy scripts) #1

wants to merge 1 commit into


None yet

1 participant

lweller commented Apr 6, 2011

This pull request is intended to show a possible extension for maven-archetype. I would be happy to become at least some feed back about utility of such a feature and chances to see this (or something similar) in maven-archetype in future.

I extended maven-achretype to allow some scripting while generating a new project from an archetype. I did'nt used the approch of an other templating engine (as suggested by issue ARCHETYPE-155), but simply added a scripting step after properties where configures. This allows to manipulate existing properties, create new ones or simply validate them.

Concretely I extended the archetype-metadata.xml descriptor like this:

First of all definition of scripts to execute after properties and before generation will start:

<script name="ComputePackage" file="scripts/compute-package.groovy" language="groovy" />

Attribute on existing requiredProperty element to specify that a property will be computed by scripting:

Script itself is a groovy script (may be extended to other languges) that has two read/write implicit variables:

  • properties : containing required properties after configuration step
  • errors : a list of strings representing several error messages (will prevent generation if not emtpy at end)


  • fully compliant with actual archetypes
  • benefit of powerful scripting language to compute/enforce some configurations

Feedback welcome. Hope this may help you to improve maven-archetype in future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment