0

I am fairly new to the Java build process. Whenever I want to create a new project, I currently create a pom.xml file and the following directories:

src/main/java
src/test/java
target/classes

Then creating a .classpath file with the following:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" output="target/classes" path="src/main/java" />
    <classpathentry kind="src" output="target/test-classes" path="src/test/java" />
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7" />
    <classpathentry kind="output" path="target/classes" />
</classpath>

Is there a quicker/easier way to do this? I am using Eclipse as my IDE (if it matters)

Cheetah
  • 13,785
  • 31
  • 106
  • 190

4 Answers4

0

You can automate the process with a maven archetype :

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

The quickstart archetype will create a basic maven structure for your project.

Source: Maven in 5 minuts

For the eclipse aspect, it exists a maven plugin to generate the eclipse configuration : mvn eclipse:eclipse (Maven eclipse plugin)

To integrate maven with eclipse you can use the maven integration plugin for eclipse(m2e-wtp). The plugin is bundled with the eclipse developer version or available from the eclipse market place.

F. Geraerts
  • 1,150
  • 17
  • 23
  • http://stackoverflow.com/questions/8393447/is-maven-eclipse-plugin-no-longer-needed-with-the-new-m2eclipse-in-indigo. – Gab Mar 17 '14 at 11:01
0

you don't need to create the classpath manually. Just install m2e-wtp eclipse plugin (or get the eclipse for JEE developers version) and it will manage eclipse classpath for you according to maven configuration.

You can also use maven archetype to generate the base skeleton (pom and directories) for a maven project according to your technology stack.

Gab
  • 7,869
  • 4
  • 37
  • 68
0

You could use the Quickstart Maven archetype

Vlad
  • 10,602
  • 2
  • 36
  • 38
0

As others pointed, you do not need to create pom.xml or .classpath by hand. IDE will do this for you.

You can do this easily by download and installing Eclipse EE . Then you just simply create

File -> New -> Other -> Maven project

This will create you a new Maven project with all directories set up for you.

Maciej Cygan
  • 5,351
  • 5
  • 38
  • 72