February 19, 2019

With the help of Groovy, we can delete a file from a generated project if it meets a condition (for instance if a maven property equals a certain value).

Here is the procedure :
1) Create the archetype. To do that, type the following command from the root of a Maven project : mvn archetype:create-from-project
result ==> [INFO] Archetype project created in E:\eclipse\workspace\celinio\target\generated-sources\archetype

Copy-paste this folder structure into another folder in the workspace and import it as an existing maven project.
By default, I have decided that this archetype will generate a project which contains a file /src/main/resources/META-INF/configuration.xml. This is the file that I do not want to include if the maven property configurable is set to no.

2) Add the following required property to /celinioArchetype/src/main/resources/META-INF/maven/archetype-metadata.xml

To test it in eclipse, you will need to create a project from a run configuration as the groovy script is not executed if you go through the wizard (File > New Maven Project > select archetype etc)
See this link for details :https://bugs.eclipse.org/bugs/show_bug.cgi?id=514993