Posts

Showing posts with the label maven

How to install Maven on CentOS

Image
Steps to install and configure Maven on CentOS Download the tar.gz file from Apache Maven site Untar the file at some location (Eg: /opt/maven) tar x z f <filename> Add the environment variable to ~/.bash_profile file cd $HOME vi ~/.bash_ profile Append PATH variable with maven path Add M2_HOME variable export M2_HOME Save and restart your system Verify maven installation mvn --version

How to generate JavaDoc jar using Maven

The maven-javadoc plugin can be used to generate a javadoc jar file, It uses JDK's javadoc.exe tools to generate javadocs, p ack in jar file and deploy along with your project. To add support of javadoc in your Maven, Just add 'maven-javadoc' plugin into your pom.xml file and specify goal as 'jar'. Example : <!-- Generates JAVADOC --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId> maven - javadoc - plugin </artifactId> <executions> <execution> <id>attach- javadocs </id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> Run it as mvn:install or mvn:package, It will generate javadoc and package it as a jar file. Reference: http://maven.apache.org/plugins/maven-javadoc-plugin/      

How to execute maven goal on parent module but not on childer

I am working on multi module maven project and If I define any plugin in the parent pom.xml file, It get executed for all the child build as well. In simple language, I wanted to use one plugin in parent pom.xml file which read properties file from the base directory but whenever I executes it, all the sub pom.xml tries to read the properties file from their base directory and its ends up in maven failed. To resolve the above issue, We just need to add "inherit' attributes in the plugin. Example : <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <version>1.0-alpha-2</version> <inherited>false</inherited> <executions> <execution> <phase>initialize</phase> <goals> <goal>read-project-properties</goal> </goals> <configuration> <files> ...

How to exclude properties file from the Jar file

Problem Statement : Suppose your are working on Java Project which uses Maven structure where your source code is under “ /src/main/java” and all your configuration files like .properties file or xml file are under “ /src/main/resources” and as a final build your final package is a jar but you want without few files from your classpath. Be default Maven plugin adds all the file which comes under resources in jar file. Solution : You can achieve the above task by using maven-jar-plugin as follows : < plugin >     < groupId > org.apache.maven.plugins </ groupId >     < artifactId > maven-jar-plugin </ artifactId >     < version > 2.3 </ version >     < configuration >         < excludes >             < exclude > **/otp.properties </ exclude >         </ excludes >   ...

maven-dependency-plugin (goals “copy-dependencies”, “unpack”) is not supported by m2e

Recently While importing one Maven project into Eclipse(Juno, m2e plug-ins is already installed in Eclipse). I was getting one error in project : maven-dependency-plugin (goals “copy-dependencies”, “unpack”) is not supported by m2e Reason: Eclipse m2e does not support execution, by copying the below code in the build tag resolve the issue. Example: <build> <COPY_CODE_HERE> </build> Code : < pluginManagement > < plugins > <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --> < plugin > < groupId > org.eclipse.m2e </ groupId > < artifactId > lifecycle-mapping </ artifactId > < version > 1.0.0 </ version > < configuration > < lifecycleMappingMetadata > < pluginExecutions > < pluginExecution > <...

How to create Spring MVC project using Maven and Eclipse

Image
This blog will show you how quickly you can  create a Spring MVC project and get it up and running, using the Maven archetype called spring-mvc-archetype . Note: First You should verify that the Maven Integration for FTP is already installed in your eclipse, If not first installed and then create a new project. Steps : In Eclipse IDE, Goto  File > New > Project Select  Maven > Maven Project and click  Next . Make sure you don’t check the option Create a simple project (skip archetype selection) , and click Next . In the next screen, Select Catalog as All Catalogs , Archetype as spring-mvc into the Filter   and select  maven-archetype-webapp in the artifact list as shown below :     In case, If you don't see the above artifact in your Archtype then Click on "Add Archetype" and Add : Archetype Group Id: co.ntier Archetype Artifact Id: spring-mvc-archetype Archetype Version: 1.0.2 Repository URL: http:...

What is Maven repository ?

Maven Repository : A repository is a place where all the project jars, library jar, plugins or any other project specific artifacts are stored and can be used by Maven easily. There are three types of repository :  local central remote  Local Repository : The maven local repository is a local folder that is used to store all your project’s dependencies (plugin jars and other files which are downloaded by Maven). In simple, when you build a Maven project, all dependency files will be stored in your Maven local repository. The default name of the Maven's local repository is .m2. Central Repository Maven central repository is repository provided by Maven community. It contains a large number of commonly used libraries. When you build a Maven’s project, Maven will check your pom.xml file, to identify which dependency to download. First, Maven will get the dependency from your local repository, if not found, then get it from the default Maven central repo...

how to install MAVEN on linux

What is MAVEN ? Read here : http://maven.apache.org/ Here are the steps to download and install Maven on linux : Step 1 : Download the latest binary from the http://maven.apache.org/download.cgi.              apache-maven-3.0.4-bin.tar.gz Step 2 : Untar it using tar command.               tar -zxvf /usr/local/apache-maven-3.0.4-bin.tar.gz Step 3: Add Maven binary Path to the System Path i,e add in .bash_profile path           $ cd $HOME           $ vi ~/.bash_profile Set PATH and M2_HOME as follows M2_HOME=/usr/local/apache_maven-3.0.4 PATH=PATH=$PATH:$HOME/bin:/usr/local/apache_maven-3.0.4/bin save the file by pressing esc : wq button Note: Don't delete the previous PATH, Just append the M2_HOME path after : Now save and clos...