Convert A Pre-Existing Non-Project To A Maven/Eclipse Project

So, you have a directory with a java class in it, and you want to use your IDE on it.  What do you do?  You can’t just open it up as a project without a little bit of work.  IntelliJ can do it from the GUI, but with Eclipse and Maven you have to do a bit more work.  Also, if this directory is already checked in you’ll want to preserve

Add a simple pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.menards.casetest</groupId>
<artifactId>CaseTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
</project>

Then add a project folder structure like this:

Now you have something you can import as a Maven project into many IDE’s.  If you are already checked into Git before this, then just move your source files under main/java/whatever path and check that move in.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>