When we create maven archetypes, specially the multi module ones, we might need to include the artifact id in to a folder or file name or include it to a content of a file. This can be done very easily.
To include artifactid to a folder or file name you just have to add the place holder __rootArtifactId__.
**Note that there are two '_' characters before and after the word rootArtifactId.
So for example if you want a file name like-development.xml, then you can simply name it as __rootArtifactId__-development.xml. When file name is mentioned like this inside the archetype, when you run archetype generate command it will replace with the artifactid provided.
Next thing is how to include this inside a file. This was tricky. I couldn't find a way to do it first. So I keep trying things and it works and it's simple. You can simply add the place holder ${rootArtifactId}.
In the same pattern you can use other parameters like version as well by using __version__ and ${version} respectively.
Enjoy !!!!
To include artifactid to a folder or file name you just have to add the place holder __rootArtifactId__.
**Note that there are two '_' characters before and after the word rootArtifactId.
So for example if you want a file name like
Next thing is how to include this inside a file. This was tricky. I couldn't find a way to do it first. So I keep trying things and it works and it's simple. You can simply add the place holder ${rootArtifactId}.
In the same pattern you can use other parameters like version as well by using __version__ and ${version} respectively.
Enjoy !!!!
Comments
Post a Comment