Hello all, I have been automating web and mobile apps for a long time. The first step of my automation journey starts with copying and pasting our base classes into the new project. Those base classes generally contain base Selenium methods, intelligent waits, string /date and DB utility classes and browser executables. So why not automate our project creation by creating our custom Maven Archetype? Here’s how you can create a Maven Archetype for your automation projects.

Step 1: Creating a Sample Project

Create a clean Maven project with all the necessary classes, executable, etc inside of it.

In this example, I also have some example PageObjects and Test Classes for newbies to understand how we handle automation logic.

Step2: Creating and Editing the Archetype

This archetype’s name will always contain the project name written in pom.xml file. In our example, it’s selenium that’s why archetype name is selenium-archetype.

By using the terminal, go to project folder containing pom.xml file and execute this command.

mvn archetype:create-from-project

At the end of execution, you will have BUILD SUCCESS message and you will notice that an archetype is created.

Go to the project folder and you’ll notice a target folder is created. Under it, there are many folders as follows “generated-sources/archetype/….”. Under the archetype folder, we have a maven project structure with a new pom.xml.

Move this archetype folder to a new folder because we are going to work on it and I don’t want you to get lost between folders 🙂

Let’s deep dive into this folder and see what do we have under it!

What’s in archetype-resource Folder?

As you can see, under archetype-resource folder we have our base project folder created with everything we need. Go to the highlighted pom.xml file under archetype folder and open it.

groupId, artifactId, version, name tags are parametrized. Those parameters will be set on the command line or on IDE while trying to create Maven project.

What’s in Maven Folder?

Under this folder, we have archetype-metadata.xml file where you can edit the content of the project structure. You can change which folder to include or exclude from project, file type to exclude or include. I leave it as it is cause I need all of those files.

Step3: Including Our Archetype to Local Maven Catalog

Go to your new folder containing pom.xml file and execute below command:

mvn install 

At the end of execution, BUILD SUCCESS message will appear and Local Maven Catalogue is updated with your maven archetype.

Step 4: Creating a New Project with New Archetype

 Go to an empty folder and run below command to create a project with our custom archetype.

mvn archetype:generate







By using groupdId, artifactId and version parameters, we set pom.xml related parameters.

Other parameters define the archetype.

Enjoy your archtype 🙂