Skip to content

Jitendra Zaa's Blog

  • Home
  • Search
  • Videos
  • About Me
  • Buy
    • Mastering Visual Studio and Salesforce DX
    • Apex Design Patterns – Salesforce

Tag: Metadata API

Auto generate Package.xml using Ant – complete source code and Video

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

  1. get Ant Migration tool jar from here
  2. get AntContrib from here
  3. create basic template of “package.xml” with placeholders in place of Report, Dashboard, EmailTemplate and Document, sample here
  4. create Ant Macro to replace placeholders
  5. create second Ant Macro to fetch all folders available using Metadata API (using sf:listMetadata)
  6. create third Ant Macro to fetch files inside each folder using Metadata API (using sf:listMetadata)
Continue reading Auto generate Package.xml using Ant – complete source code and Video
Published January 1, 2015
Categorized as Salesforce Tagged ANT, ANT Migration Tool, Metadata API, Salesforce, XML

Search Blog Content

Subscribe to Blog via Email

Never miss a post. Provide your email address to get latest blog posts, right into your email box.

Join 1,957 other subscribers

Archive

  • Twitter
  • LinkedIn
  • Youtube
  • Facebook
  • Trailhead
Proudly powered by WordPress.