Maven: Convert non maven projects to maven project

3 min readDec 29, 2020

I will show using IntelliJ:

  1. Right click on the project-> Add Framework Support

2. Now select Maven

Now the pom.xml will be opened and give values for groupId, artifactId and version as your choice

Since the project was not maven project, find if it was using and libraries.

Right click on the project rot and click -> Open Module Settings

Under project setting->Libraries you will find all the libraries being used

We will add these in the pom.xml file

Goto pom.xml and right click->Generate (You can also press alt+insert)

Now click on Dependency

In the serach box, search for the jar file, for our above example we will add commons-io version 2.4

You will see that the dependency is automatically added

Similarly add all the other dependencies.

Add external dependencies

Look if there is any external libraries in the project

So, I have Java 1.8 and JUnit 4.

Let’s add those!

Add Java 1.8

Add the below section outside dependencies section:






Now add the JUnit4

Add it like before (generate->Dependency…)

Just add <scope>test</scope>


How to add a Jar which is not available in Maven central repo?

Best way to add that in your companies repository, you can set up using Nexus, or Artifactory or something similar

But for now, just put that in the lib folder and reference that from maven:

<!--FIXME: add this jar in Nexus and use from there-->


Right click on the pom.xml-> Maven-> Reload project


Now compile the project to see if there is any error:

You can also go to the project and from command line do:

mvn compile