If we want to use Ant Migration tool to fetch Salesforce Organization metadata info or to deploy some changes to Salesforce, we need to create “package.xml” manually or take help of eclipse. wildcard character (*) doesnt work with some components like report, emailtemplate, dashboard and document. Package.xml must needs to have folder name and files inside folder name. After getting package.xml from eclipse, what if some folder is added into Organization ? We need to update “package.xml” again with help of eclipse or do it manually. Therefore I wanted to automate generation of package.xml completely and came up with this article and below workaround.
I would be using Ant to generate “package.xml” with below steps
- get Ant Migration tool jar from here
- get AntContrib from here
- create basic template of “package.xml” with placeholders in place of Report, Dashboard, EmailTemplate and Document, sample here
- create Ant Macro to replace placeholders
- create second Ant Macro to fetch all folders available using Metadata API (using sf:listMetadata)
- create third Ant Macro to fetch files inside each folder using Metadata API (using sf:listMetadata)