Wednesday, July 1, 2009

Maven setup behind firewall and NetBeans

Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.

Installation and Usage guidelines:

  1. Goto the download section of http://maven.apache.org, download and extract it to your apache home folder in your computer (c:\program files\Apache Software Foundation\).
  2. Create listed environment variables:
    1. M2 with {Maven folder path}\bin
    2. M2_HOME with {Maven folder path}
  3. Update the "PATH" environment with the {Maven folder path}\bin value.
  4. If you are accessing the internet through a Proxy server, you need to provide proxy information to the Maven installation also. Go to the {Maven folder path}\conf, open the settings.xml file and update the proxy value in the following tag:

    <proxies>

        <proxy>

          <id>optional</id>

          <active>true</active>

          <protocol>http</protocol>

          <username>{your user name}</username>

          <password>{your password}</password>

          <host>proxy-server</host>

          <port>proxy-server-port</port>

          <nonProxyHosts>127.0.0.1</nonProxyHosts>

        </proxy>

    </proxies>


     

  5. Go to the command promp and type "mvn install", it should start installing basic modules required to run maven in {user home directory}\.m2 folder.
  6. You can change the default home folder path from {user home directory}\.m2 to anything else like "c:\m2" from the {Maven folder path}\conf\settings.xml file by giving the new path in <localRepository> tag. Once you change the path you need to fire the "mvn install" again to generate the basic maven structure or copy it from the old repository structure.
  7. Early NetBeans IDEs are providing the Maven interface with the additional plug-in support. Moreover new IDEs (6.5 onwards) Maven is integrated in the basic installation.
    1. NetBeans also required Maven configuration to use integrated or external installation. For external Maven go to the "Tools -> Options -> Miscellaneous -> Maven" and provide external Maven home path.If using the integrated Maven of NetBeans one has to configure the Proxy settings of NetBeans to allow central repository access.
    2. You can create Maven project by "File -> New Project -> Maven -> Maven Quickstart Archetype".
    3. Sub-project or Third-party dependencies can be easily given by "Add dependency" option in the "Libraries" node of the project.
  8. For further information go to http://maven.apache.org.
  9. Maven encourages the Test Driven Development, so please start understanding and writing the Junit test cases for the code.