Maven 2 has the notion of archetype. It is a template of a project which is combined with some user input to produce a working Maven project that has been tailored to the user's requirements.
Some other projects are trying to achieve same goal by using similar or slightly different approaches:
- AppFuse 1.x; (light) - uses Ant scripts to generate template;
- AppFuse 2.x; - uses Maven2 scripts to generate template;
- Able Project (https://svn.opensymphony.com/svn/sandbox/able);
- HSE (Hibernate, Spring, Echo2) Project;
- Archy project.
Archetypes program is based on my previous scripts (see my
previous post) and also inspired by Archy project.
All definitions of archetypes and repository locations are decoupled from source code into external xml file (archetypes.xml).
All archetypes are divided by groups. Group is the list or archetypes that has
same groupId, version (e.g. AppFuse, Maven2 or WebTidy groups).
Each archetype has name, description and version (if different from group version). All archetypes from same group are located in same repository. For example AppFuse fragment looks like:
<groups>
...
<group name="Appfuse" groupId="org.appfuse" prefix="appfuse-" version="2.0-m5" >
<archetypes>
<archetype name="basic-jsf"
description="Archetype for creating a web application with Hibernate, Spring and JSF"/>
<archetype name="basic-spring"
description="Archetype for creating a web application with Hibernate, Spring and Spring MVC"/>
...
</archetypes>
<repositories>
<repository>http://static.appfuse.org/repository</repository>
</repositories>
</group>
...
</groups>
In order to run the application you have ho have Scriptlandia
project installed on your computer. It will take care of downloading all required dependencies, installing them locally on your computer and then executing Beanshell script. Otherwise, you have to be ready to do this manually.
Program can function in 2 modes: console and gui. For console mode you have to execute the following command:
>create-archetype.bsh -console
Program will ask the user about archetype group name and archetype name. Then, for your application, you have to specify groupId, artifactId and version. For these parameters Archetypes program will generate the resulting template in current directory.
For "gui" mode you have to execute the following command:
>create-archetype.bsh -wait
"wait" parameter is used my Scriptlandia framework to indicate that our script should wait for completion of gui/swing thread execution. Otherwise, frame will appear for very short time and just after that script execution will be terminated.
In "gui" mode you will see same input parameters, just layed out in more convenient for typical Windows user. After selecting appropriate archetype and clicking on "Create archetype" button, new project will be created in the current directory.
This program uses behind the scene
Scriptlandia API to execute maven2 tool:
ScriptlandiaHelper.executeMaven(args);
The source for this script is located here or within examples for Scriptlandia.
Hope tis program will save you time for your family and friends!
-