Thursday, November 6, 2014

Maven Basics

What is Maven?
  • Maven  is a S/w Project Management Tool that provides the Project Object Model [POM file] to manange the Project Builds, Dependencies, Documentations, Mailing List.
  • Powerful Feature of Maven is that it's ability to download the dependencies automatically.
Why Maven?

Common Problems we face in S/w Development is that 
  • Each Project Type has it's own structure and there is a need to take care of it.
  • Requirement of Multiple Jars and other Dependencies. For each framework like Spring, hibernate etc we need to be aware of the Jars Required for the Corresponding Versions.
  • Build Process and Deployment 

Apache group mainly developed Maven to build multiple projects together, publish projects information, deploy projects, share JARs across several projects and help in collaboration of teams.

How to SetUp Maven?


  • Dowlaod the latest version from http://maven.apache.org/ and unzip it.
  • Set the Environment Variables MAVEN_HOME / PATH / JAVA_HOME as below.


  • That's it. Once done open the cmd and type  to check if everything has been set well.
How to setup a Project Structure via Cmd Prompt?
  • Run the cmd mvn archetype:generate from Cmd Prompt.
  • We get a list of predeined archetypes.



  • Archetype refer to the prototype how we want to structure our project. It requests for versions in some cases and other properties like groupId [similar to package name], artifactId [similar to project name], 
Now if we look into the directory, we find the well defined Project structure with pom.xml carrying all the required details about the Project Structure, Dependencies, ArtiactId etc., 

artifactId 
|_src
      |_main
               |_java
               |_resources
      |_test
|_pom.xml

Let's see how to run the Project. Check if have the sample hello worldwithin the java directory above.

  • Run the Command mvn comile. This downloads all the required jars and compile the class files to the artifactId->target directory
  • Now run the command mvn package. This builds not only jar but also run all test cases, so we don't have worry about running the Unit Tests manually.
  •  Now roll the Java Main method with  java -cp foo.jar full.package.name.ClassName


Architechture of Maven:


  • We setup Maven in Dev Environment.
  • Maven contacts Maven Repository to fetch the dependencies.
  • Maven holds two types of Information - Archetype and Dependency Information. 




mvn archetype:generate -> This command contacted Maven Repository and fetched the list of Archetypes. Once we provide the required Archetype as Input, the project structure was created along with POM file as below.




mvn: compile -> Maven reads pom.xml, contacts Maven Repository to download all the required jar dependencies and virtually places them inside the directory structure. Once done, compiles the Source Code.

mvn: package -> This command packages all the directory structure and provides the build. In our case it is the JAR file.

With the above three simple commands, Maven helped us achieve the Directory Structure, Choose the Right Dependencies, Compile and finally Package it.

Maven Build Process:

       Irrespetive of Maven, all builds follow certain Build Life Cycle. Build Life cycle constitutes many Phases [example: compile, package]  indeed. A typical Maven Build Life Cycle constitutes four phases:




Whenever we run a specific phase, other phases below run implicitly. For example if run package phase [resource gets prepared and compiled and finally packaged]

Note: Install command is Maven specific. It does not installs the war/ jar into Tomcat. It just instals into Maven Repositary [most often it is in our System]. Incase of any dependencies, Maven first looks into the Local Repository, it downloads if and only if it couldn't fetch from the Local.

Location of Maven Local Repository is C:\Users\Ananda\.m2\repository

Thursday, October 9, 2014

Perforce Server SetUp

What is Perforce?

Perforce is a commercial, proprietary revision control [an aspect of SCM] system developed by Perforce Software, Inc.

A typical Perforce employment includes the Perforce Server along with the Client [may be a Git Client or the Client that uses Perforce's own Protocols]

Note: Git clients communicate with the Perforce server over SSH or HTTPS, and other Perforce clients communicate with the server via TCP/IP using a proprietary RPC and streaming protocol.

Perforce Architechture

Perforce Server

       The Perforce server manages a central database and a master repository [Depot] of file versions.
    • Perforce Database

1.      Database is proprietary, preconfigured, and self-installed.
2.      MD5 hashes of file content are stored in the Database instead of the actual File Contents.
3.      System-related metadata (file state, file attributes, branching and merging history, changelists, change descriptions, users, groups, labels, etc.) are stored as well.

    • Perforce Depot
1.     Versioned file content is stored in a master directory hierarchy whose top levels are called "depots".
2.     All revisions are preserved by default; limits can be set on the number of revisions preserved.



Perforce Architechture

Perforce Client
    • Client Workstation requires the Perforce Client to connect to the Server and fall into roughly five categories:  Git, Command, GUI, Web, Plugin. 
    • Perforce Client provides the access to the Versioned files.


   Perforce Server  and Client SetUp:

  Perforce Server Setup

     Step 1: Navigate to the Perforce Site - http://www.perforce.com/downloads/Perforce/20-User and download P4D Server  

Perforce P4D Server at Perforce Site











     Step 2: Double Click the Downloaded executable and double Click it. You will provided with the below Screen. Select Next.


Perforce Server Components

      Step 3: We'll be asked to provide the Port for other Client Machines to connect to this Perforce Server. Let's make it to default 1666.



Perforce Port Number
 Step 4: Once given Next, it's time to chose the Default Text Editing Application for Perforce. Let's make it to be  the  Legacy Application Notepad. Click Next. The Setup would initialize the Perforce Database and finally provide us the connection details which needs to be shared with the Client.

Text Editing Application Selection

Step 5: Finally the Setup would just provide us the the hostname along with the port number that needs to be shared to the Client Applications as in the below Screen. Make a note of it. Click Finish 













Perforce Client SetUp:

Step1 : Navigate to the Site http://www.perforce.com/downloads/Perforce/20-User and download P4V Client.  



















Step 2: Once P4V Client is downloaded, double click the executable to instantiate the installation procedure. We''ll be provided with all the components [p4Admin for UserManagement, p4V Visual Client for Workspace, Depot Access , p4 Command Line Perforce Tool] that can be installed per need. Once the Components are Selected, Click Next. 





Step 3:  Next we need to provide the details of the Server for the client to connect to. Here it is Ananda-VAIO:1666 [ Refer Step 5  metioned few snapshots above under Perforce Server SetUp] . Click Next. 




Hurray !! We've set up the Perforce Server and Client.   

Saturday, August 16, 2014

CVS Repository : Setup Guide

What is CVS?
  • Client/server system that controls the Software revision.
  • Vital component of Source Configuration Management (SCM).
  • Keeps track of all the works and changes in a set of files.
How CVS works?
  • CVS Server Software stores the current version of Project and it's history.
  • With CVS Client, developers connect to server -> Check Out the files -> Implement the required changes -> Check In the updated version.
How to Set Up the CVS Server Repository in local
  • Download CVS Suite 2009 R2 from [ http://march-hare.com/cvspro/ ].
  • Installation of CVS Suite:
         Step 1: Login as Administrator [we would be using Administrators  username and Password later for connecting to CVS Server] and install CVS Suite.


        
              Step 2: Select Server [ Here we gonna install only the Server Specific components and regarding CVS Client, Eclipse Users would utilize the CVS Client Eclipse Plugin. While other Users can make use of Client Components integrated along with this suite. Again repeat We gonna walk through only CVS Server Installation in this Tutorial]




             Step 3: At this moment CVS Server Configuration would run for few minutes. Please wait for a while.


              Step 4: We are done with the CVS Suite Server Component Installation. Click Finish.


  • Open CVS Suite Server 



  • Navigate Repository Configuration. Click Add.


  • Provide the Directory Location which ought to be treated as the CVS Repository. Hit OK.




  •  Now time to connect to CVS Local Repository from Eclipse. Open Eclipse -> Add CVS Repository.