Site icon Automation Dojos

How To Create Maven Project in Eclipse Without Archetype

Maven is a very popular build and dependency management tool. Eclipse is an IDE that helps developers write and run Java code easily. In this article, I will be explaining how you can create a Maven project in Eclipse.

Maven Basics

Maven automates the steps involved in building a software application like adding the JAR files, compiling code, running unit tests, creating the output jar/war file, etc. This makes the code less error-prone. Maven uses an XML configuration file known as the POM file. Developers need to specify information like the JAR files required by an application, the type of output artifact (jar,war, etc). Maven then uses the instructions in the POM file to build the application.

Eclipse Maven Integration

Most of the recent Eclipse releases already include Maven. So, developers do not need to do anything special to install Maven in Eclipse.  However, some earlier versions of Eclipse do not include Maven, so it needs to be installed explicitly from the Eclipse marketplace. Once Maven is set up with Eclipse, it allows you to easily create a Maven project and use all the Maven features like dependency resolution within Eclipse itself.

Creating a Simple Maven Project

In order to create a simple Maven project in Eclipse, the following steps need to be followed:

Create new artefact of type ‘Other’

From menu File > New select ‘Other’

Select Maven Project. Click Next

On the ‘new project’ wizard select ‘Maven Project’

Select ‘Create a Simple Project’

Click the Create a Simple Project (skip archetype selection) checkbox. Click Next

Enter value for Group Id & Artifact Id.

Change version and packaging

Change version and packaging if required (This is an optional step). Click Finish

New Maven Project Created

This creates a Maven project in Eclipse with the Maven directory structure and POM file as follows

View Your POM File

The default POM created has the group id, artifact id, version and packaging specified at the time of creation as follows

Finish!

This POM file can then be modified by adding dependencies and other information as required.

[td_smart_list_end]
Exit mobile version