In my maven archetype definition, I would like to set the default version to 0.0.1-SNAPSHOT when the user doesnt enter anything. However, when I create a project based on the archetype, I am always prompted for the version and the default is 1.0-SNAPSHOT.
How do I do this correctly?
I defined a version property in the archetype.properties file and when I compile the archetype, it says the correct version and when I change the value in the archetype.properties, I can see that the console output changes accordingly.
Just on creating a project based on the archetype, I get prompted for the version again.
Thanks for help and tips!
(I'll provide code if necessary)
You can define custom properties in you archetype metadata. Have a look at the
archetype-metadata.xml
inMETA-INF/maven
. For example:A custom property for
version
would look like this:More details in the docs.
When you run the
mvn archetype:generate
command referencing an archetype with the above configuration you'll see this in the console output:Or, if you run the
mvn archetype:generate
command with the parameter-Dversion=FOO
then you'll see this in the console output:Note: this version is, of course, separate from the
archetypeVersion
which defines the version of the archetype itself rather than the version of the module produced by the archetype.