Friday, June 26, 2015

Steps to create java project with maven


To create java project from maven template


  • Go to command project and navigate to the folder you want to create the project
  • Type the command

    mvn archetype:generate -DgroupId={project-packaging}
   -DartifactId={project-name}
   -DarchetypeArtifactId=maven-archetype-quickstart
   -DinteractiveMode=false

where {project-packing} and {project name} are the name of the package and project name provided.

  • Above command creates the project with maven-archetype-quickstart template.
  • Thus it will create /src/main/java and /src/test/java folder structure with pom.xml file.

  • To make this eclipse project, navigate to your project folder in command prompt,

 type mvn eclipse:eclipse

.project  will be created.

  • In Eclipse, File -> import -> Existing project from workspace.

Add compiler plugin in the pom.xml to tell maven which JDK version is used to compile your project.

         <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>




Friday, September 26, 2014

Apache Maven - Manages your Software Project

This blog is about the installation steps of Apache Maven on Windows OS.

Apache Maven is a project management and comprehension tool. Maven provides developers a complete build lifecycle framework.Maven simplifies and standardizes the project build process. It handles compilation, distribution, documentation, team collaboration and other tasks seamlessly. Maven increases reusablity and takes care of most of build related tasks.

Download Maven

Here is a link to download the current version of Maven

http://maven.apache.org/download.cgi#Installation

Select binary file from list of options to download.

Once downloaded, extract it to the location where you want to install it.


Extracted folder will look this structure..

bin
boot
conf
lib
LICENSE.txt
README.txt
NOTICE.txt

Next Step would be setting up an environment variable for Maven.


Variable Name : M2_HOME
Variable Path :  %Maven home% (Assuming you have extracted the maven folder )

Variable Name : “M2”
Variable Value : %M2_HOME%\bin

Maven requires JDK to be installed properly. Check if JAVA_HOME environment variable is properly set or not.

After doing the above steps, its time to check whether maven is installed or not

To check installation of Maven open command prompt and type the following command

mvn --version

If output is “’mvn’ is not recognized as an internal or external command, operable program or batch file.” Then there is some problem in the path of Maven folder. Check your envirnoment variable.

If it is installed properly, you can see the output like this on your command prompt

Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-12T02:28:1
0+05:30)
Maven home: D:\apache-maven-3.2.3-bin\bin\..
Java version: 1.7.0_55, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_55\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"