Showing posts with label pom.xml and Mvn archeytype. Show all posts
Showing posts with label pom.xml and Mvn archeytype. Show all posts

Wednesday, 17 June 2015

Steps to create Maven Project from Command line

Below are the steps to be followed for creating a simple Maven project from command line.

1.  Please make sure the enviroment is setup. please see the previous post on how to set up
     the Maven environment.

2. Open command prompt and go to the folder where you want the project to be created
     and type the below command.
       mvn archetype:generate -DgroupId=com.myapp  //Project packaging
      -DartifactId=mavendemo  //Project name
      -DarchetypeArtifactId=maven-archetype-quickstart  //Template
      -DinteractiveMode=false 

  • The above command creates a project mavendemo with the entire project structure based on the "maven-archetype-quickstart" template.
  • It will also download all the required dependencies from the Maven central repository and store it in local repository.
  • All the source code will be put under src/main/java folder and all the test code will be put under src/test/java
  • It will also create pom.xml. It is the Project Object Model which is the fundamental unit of work in Maven. It contains all the project information like plugins, dependencies, directory sturcture, configuration details to build the project.

If you want the project to be imported into eclipse, follow the below steps.

3. go to the project folder where it is created (in our ex: mavendemo folder) and type command
    mvn eclipse:eclipse. This will generate the eclipse related env files like .classpath
    and .project.

4. In eclipse go to File-> Import -> General -> Existing Projects into Workspace.