Showing posts with label Maven. Show all posts
Showing posts with label Maven. Show all posts

Unable to view Convert to Maven in Eclipse Juno IDE for J2EE

While I was working on issue of converting my Java Project to Maven, I found that there is no options like configure-> "convert to Maven Project" on my current working project which is being discussed in existing forums.

Solution :
You need to add M2E(Maven Integration for Eclipse Plugin) to Eclipse Juno J2EE IDE from location http://download.eclipse.org/technology/m2e/releases

What is Maven and Why to use it?

Apache Maven is a basically used for managing project's build, reporting and documentation. Maven is based on model which is called POM(Project Object Model).

Consider example that you need to use log4j for your application for logging.

In Usual way , you need to search,download and add log4j.jar into your project dependency and what if  upgraded version of log4.jar is available and you want to add into your project. You have to do this manually. Maven can assist you in order to overcome with this manual process.

In Maven, you need to know "maven coordinates" for library you want to add into your project. Ex. coordinates for log4.j which you can find at Maven Central Repository

Once you have groupId,artifactsId and version available then You should add following lines into your Project's pom.xml

Maven Local,Central and Remote Repositories

Maven repository is divided into 3 types :
  1. Maven local Repository
  2. Maven Central Repository
  3. Maven Remote Repository

Maven local repository :  It' place where all project dependency libraries which are specified in project's pom.xml are stored here after downloaded by Maven
Default to home directory is
    1. Unix/Mac OS X – ~/.m2 on 
    2. Windows – C:\Documents and Settings\.m2 on Windows
    This default location can be change by editing conf/setting.xml
    <!-- localRepository
       | The path to the local repository maven will use to store artifacts.
       |
       | Default: ~/.m2/repository
      <localRepository>/path/to/local/repo</localRepository>

    How to enable Proxy setting in Maven

    Considering that you have installed maven and environment variable M2_HOME is pointing to installation directory of Maven and %M2_MAVEN%/bin is appended to your environment variable %PATH%.

    Open setting.xml from %M2_HOME%/conf/settings.xml. 
    UnComment following code and add your Proxy Details.

    <proxies>

        <!-- proxy
         | Specification for one proxy, to be used in connecting to the network.
         |
        <proxy>
          <id>optional</id>
          <active>true</active>
          <protocol>http</protocol>
          <username>proxyuser</username>
          <password>proxypass</password>
          <host>proxy.host.net</host>
          <port>80</port>
          <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
        </proxy>
        -->
      </proxies>

    Save file. Please note that no restart 

    Apache Maven Installation and Maven Configuration

    Maven : Apache Maven is a basically used for managing project's build, reporting and documentation. Maven is based on model which is called POM(Project Object Model).

    Installation :

    1. Download Maven from http://maven.apache.org/download.html eg.version Maven 3.0.4
    2. unzip into any Directory. ex. C:\Program Files\apache-maven-3.0.4(Windows) or /usr/local/apache-maven/apache-maven-3.0.4(Unix)
    3. Add Environment variable M2_HOME = <Installation dir without bin directory> or export M2_HOME = <path of installed without bin>
    4. append %M2_HOME%\bin into PATH Environment
    Unix : export M2=$M2_HOME/bin and export PATH=$M2:$PATH
    6. Optional – add the environment variable MAVEN_OPTS to specify JVM properties, e.g.
    Windows : MAVEN_OPTS = -Xms256m -Xmx512m
    Unix : export MAVEN_OPTS=”-Xms256m -Xmx512m”
    5. goto cmd and check Maven as : mvn -version