Newbie question here, I have a maven archetype that I'm creating from a java project using a .properties file. I want to be able to generate dynamic values for variables within the archetype and I'm not sure how to do that. Currently I'm following this maven guide and but I can't seem to reproduce what they've done. Specifically at the bottom of the guide where they replace the String value with a new value.
Here's the properties file I'm using:
archetype.groupId=com.mycompany
archetype.artifactId=sample-project
archetype.version=1.0
archetype.languages=java
myParam=something
I checked my archetype-metadata.xml file and the properties I'm trying to load are in there:
<requiredProperty key="myParam">
<defaultValue>new value here</defaultValue>
</requiredProperty>
However, none of my classes have the new value loaded. Is there a step that I'm missing that replaces the default value of the parameter and replaces it with the new value specified in the prop file?
Thanks in advance!
You are probably right, there is not any fragment how a
App.java
or others class look likes after creating archetype and before creating a project.Assuming you dont know how to use your custom properties, and your final
App.java
class need to look like this (just an example):And your
archetype.properties
file looks like this you pasted, your ArchetypeApp.java
class (before installing archetype!) need to look like this:if you got prepared file like this, you can easly
mvn install
this archetypethen if u create project you will be ask to confirm a values from properties file. And thats all. Value from archetype.properties should be applied