I'm trying to create an archetype that will conditionally include a file based on user input.
For example, if the user will use this own archetype and pass parameters such as
-DprojectType = webProject or -DprojectType = webDBProject
if webProject copies only files related to webProject, and if its webDBProject copies files related to webProject and files associated with the database.
I found that conditionally including / excluding a file is impossible, at least in the near future, using an archetype descriptor.
How can I conditionally include or exclude a file from an archetype when creating a project?
Another option that I had was to fulfill the goal after generating the archetype and include / delete unnecessary files. But we cannot use the eclipse M2E plugin with this.
The last option I tried is to use the speed template itself to perform post-processing operations.
Since we cannot create an instance of the object inside the speed template, I tried to use reflection to create an instance of the file and delete some file, as shown below:
$somestring.getClass().forName("java.io.File").getMethod("delete", null).invoke($somestring.getClass().forName("java.io.File").getConstructor($somestring.getClass()).newInstance("delete.txt"), null)
writing the above line to the speed template file and running it on an isolated speed java program works fine. But the same does not work when executed as part of the Maven archetype generator.
I tried to go step by step where the execution was successful until the class was received, but the getConstructor () part does not execute when archetype: generate is run.
Has anyone tried to find out the reason or found an alternative solution?
Also does anyone know which version of the speed engine is used in Maven?