Prerequisites for
Using the Force.com Migration Tool
- JAVA (JDK latest version) use java -version in cmd to know the version of java in your machine
- ANT (latest version) Use Ant -version in the command prompt to know the version of ANT in you machine
- Migration Tool (Download latest version from the Salesforce)
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
- Extract the Migration Tool Zip file in your local directory, available in Salesforce at :Setup-> Tools ->Force.com Migration Tool
- Copy the "ant-salesforce" jar file from the extracted folder and paste within lib folder where Ant is installed.
- Open the Build.properties file from the Migration Tool folder. In the build.properties, update the credentials:
- Put your package.xml in the folder Migration Tool - > unpackage
- 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
- 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:
- 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
- Open ANT batch file in notepade++ Set ANT_OPTS =-Xmx2048m JAVA_OPTS = - Xmx2048m in the setDefaultAntHome as below: