Maven: Convert non maven projects to maven project

Add external dependencies

Look if there is any external libraries in the project

Add Java 1.8

Add the below section outside dependencies section:

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>

<source>1.8</source>
<target>1.8</target>

</configuration>

</plugin>
</plugins>
</build>

Now add the JUnit4

Add it like before (generate->Dependency…)

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>

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

<dependency>
<!--FIXME: add this jar in Nexus and use from there-->
<groupId>give-any-name</groupId>
<artifactId>give-any-name</artifactId>
<version>give-any-version</version>
<scope>system</scope>
<systemPath>${basedir}/lib/name-of-the-jar.jar</systemPath>
</dependency>

Reload

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

Compile

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

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store