

MetadataService.InstalledPackage installedPackageA = new MetadataService.InstalledPackage() Note fullName in the samples below is used to pass the namespace of the managed package being referenced. This is how its done via the Metadata API directly, in Apex (though the following is more or less the same in Java). Note: The packagePassword attribute is optional.

You can download the ant-salesforce.xml file containing the macro.

To make things easier, I’ve put together a couple of Ant marcos to distill its use a bit further. Though it still requires the usual folder structure and package.xml file before using the usual sf:deploy Ant task. You can only deploy the new InstalledPackage component type that describes the package to install, on its own. I’ve placed the ant-salesforce.jar file in a lib subfolder as per the reference in the sample below. You’ll need to download the Migration Toolkit from your Tools page. So first lets look at doing this via Ant. In addition this is also a useful API for building package management tools and UI’s to help administrators install other packages you offer via a kind of package menu! Thus I’ll show how to use it from my Apex Metadata API wrapper. Where they are deploying code which requires dependent packages to be installed before deployment. No, your eyes are not deceiving you! Since the Summer’13 release, you can now automate the installation and uninstall of managed packages! The main use case for this I guess is for those building Continuous Integration build systems using Apache Ant.
