About Me

My photo
PLANO, Texas, United States

Sunday, August 2, 2015

ANT Tool

Prerequisites for Using the Force.com Migration Tool
  1.  JAVA (JDK latest version)  use java -version in cmd to know the version of java in your machine                             
  2. ANT (latest version) Use Ant -version in the command prompt to know the version of ANT in you machine 
  3. Migration Tool (Download latest version from the Salesforce)
Follow the below steps for using Migration Tool:

Step 1: Create the below User Variables
If you have admin right:
Create the below User Variables (Right Click My Computer -> Properties -> Advanced System Settings - > Environment Variables - > User Variables)
If you do not have admin right:
Then Control Panel -> User Accounts-> User Accounts -> Environment Variables - > User Variables

  • JAVA_HOME = <path where jdk is installed in your computer>         
    • Example - C:\Program Files\Java\jdk1.8.0_25   
  • ANT_HOME = <path where ant is installed in your computer>
    •   Example C:\Program Files (x86)\apache-ant-1.9.4
  • PATH <path where jdk bin is installed in your computer>; <path where ant is installed in your computer>
    • Example  C:\Program Files\Java\jdk1.8.0_25 \bin;C:\Program Files (x86)\apache-ant-1.9.4/bin
Step 2: Setup SFDC Migration tool

  1. Extract the Migration Tool Zip file in your local directory, available in Salesforce at :Setup-> Tools ->Force.com Migration Tool
  2. Copy the "ant-salesforce" jar file from the extracted folder and paste within lib folder where Ant is installed.
  3. Open the Build.properties file from the Migration Tool folder. In the build.properties, update the credentials:
  4. Put your package.xml in the folder Migration Tool - > unpackage
  5. Retrieve the meta data from the Source org using the below command – Please note the credentials given in build.properties are of source org.  
    ant retrieveUnpackaged 
  6. Change the credentials in build.properties and update with the Target org and run the deploy command for the validation as below:ant deployUnpackaged
Issue Faced:
Proxy Setting Issue
Proxy issue can be resolved by configure in the build.xml file as below:
     <target name="proxy">
 <property name="proxy.host" value="*.**.***.*" />
 <property name="proxy.port" value="**"/>
<property name="proxy.user" value=""/>
<property name="proxy.pwd" value=""/>
<setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}" proxyuser="${proxy.user}" proxypassword="${proxy.pwd}" /></target>
Also use depends="proxy" in the target tag as below:

<target name="retrieveUnpackaged" depends="proxy">
      <!--<mkdir dir="retrieveUnpackaged"/>-->
      <!-- Retrieve the contents into another directory -->
 <sf:retrieve username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="RetriveFromOGTestForbug" unpackaged="RetriveFromOGTestForbug/package.xml"/> </target>

Heap Size Issue:
If migration code is very large then we can get Heap size issue. I have faced this issue and we have resolved it as below:
  1. Go to ANT directory (Where ANT is installed) for example: in C drive as below:                   C:\apache-ant-1.9.4-bin\apache-ant-1.9.4\bin
  2. Open ANT batch file in notepade++                                                                                            Set ANT_OPTS =-Xmx2048m                                                                                    JAVA_OPTS = - Xmx2048m in the setDefaultAntHome as below: