Retrieving Unpackaged Components

note: The Ant Migration Tool is retired with Spring ’24. The tool continues to function as-is for future API versions but isn’t updated with new functionality and isn’t supported. If Salesforce adds a new feature that is incompatible with Ant, the Ant Migration Tool won't be updated to support it. To manage metadata changes, switch to Salesforce CLI for a modern, supported developer experience.

The unpackaged package contains all of the standard objects, custom objects, Apex classes and other metadata components that exist natively in your organization, and not within a package. To retrieve unpackaged components, use a build.xml target that contains the unpackaged attribute that points to a package.xml file. For example:

<target name="retrieveUnpackaged">
  <mkdir dir="projectFolder"/>
  <sf:retrieve 
      username="${sf.username}" 
      password="${sf.password}" 
      sessionId="${sf.sessionId}"
      serverurl="${sf.serverurl}" 
      retrieveTarget="projectFolder" 
      unpackaged="unpackaged/package.xml"/>
</target>

The salesforce-ant.jar file contains Ant tasks for accessing the Metadata API. In the code above, sf:retrieve is an Ant task. The full list of metadata Ant tasks are described in the Metadata API Developer Guide.