top of page

Create a new Maven project

On your computer, open the command line. Navigate to the location where you want to create a new project and type the following command:

mvn archetype:generate 

You will get a huge list, suggesting what types of projects you can create. A suggestion is made for you at the command line cursor (near the text 'Choose a number or apply filter'). Type in the suggested number. This will generate a 'maven-archetype-quickstart' type of project. This will generate a very basic project for you to work with. Next, you will be asked for this type of project's version. Type in the suggested number. Next you need to enter the groupID. This information will uniquely identify your project, and it must follow the naming conventions that Java developers adhere to: . For the purpose of this tutorial, i will create the following groupID: ''.

For the artifactID, enter the name for your project. For this tutorial, i will create the following artifactID: 'testproject'.

For the version property, enter the following information: '1.0-SNAPSHOT'.

For package just enter 'jar'.

After this, you will get a confirmation screen. Type 'Y' to confirm the information you just typed in. You will get a 'Build Success' screen, which means the project compiled and the project's files are properly structured inside folders and packages.

The next step is to import the generated project into your IDE. It needs to be imported as a Maven project. The information on how to import the Maven project can be found here: for Intellij - and for Eclipse - . By examining the project structure, you will have the following folders (screenshot is generated by Intellij, so the .idea folder and the .iml file are specific to this IDE).


Notice you now have the two folder structures: src/main/java and src/test/java. The developer's code will be places within the 'main' folder, the tests will be placed within the 'test' folder. After successfully importing the project into the IDE, open the pom.xml file.  Edit the file, so that you are only left with the following information in the file:

<project xmlns="" xmlns:xsi=""



Also, delete any file or folder that might appear in the following location within your project: src/main/java and src/test/java. These are default files generated by Maven for the specific project type you chose at the 'generate archetype' step (because you chose 'jar' for the 'package' parameter when you generated the project, you will have a 'jar' folder inside the two folders mentioned above, each folder containing a class, that you won't need in your tests). Now, from the command line, browse to your project's location. Type the following command:

 mvn clean install 

This command should now return a 'Build Success' message. This means the project has successfully compiled and it is ready to be setup for your testing needs. The next step is to import the testing dependencies, which you will learn how to do here: For more information on what the pom.xml file is, you can read this documentation from Maven:

bottom of page