I'm using Ant to deploy from within Eclipse and facing a challenge of having to manually manage my package.xml files.

Currently I am unhappy that I a) have to manually manage my package.xml entries and b) can only deploy all objects in my project.

So these are separate but possibly related problems:

  1. Can eclipse or the force.com plugin automatically generate the package.xml file for me? In some of my projects it is there and contains objects, in others it is empty. A refresh from server does not change it. I would expect it to at least contain all subscribed objects.

  2. The sf:deploy target complains if there are files in the folder which are not in package.xml If I want to deploy only selected objects I have to manually generate a package.xml and make a new folder with only those classes.

  3. Is there a way in ant to have targets use a different package.xml?

[target name="deployAll"] [sf:deploy username="${sf.username}" package="package.xml"/] [/target]

[target name="deployBasic"] [sf:deploy username="${sf.username}" package="package.basic.xml"/] [/target]

If anyone else is also using Ant I would appreciate some tips.

  • At least part of this appears to be a duplicate of this question here: salesforce.stackexchange.com/questions/7447/…
    – pchittum
    Jan 24, 2013 at 16:34
  • I did read that before posting and it confirmed my suspicion that my package.xml should be getting generated automatically via refresh but isn't :-(
    – Marc
    Jan 24, 2013 at 16:56
  • 1.I am also trying for the same thing what you have mentioned like generating package.xml automatically. Have you got any solution for that???
    – user38346
    Oct 18, 2016 at 15:29

3 Answers 3


I am using ant together with Jenkins and indeed you need to generate the package.xml yourself or use that one from the eclipse project.

I found this salesforce migration guide very usefull to see what you can add in the ant script to retrieve/deploy


  • Thanks for that link. It seems to definitely preclude specifying a different package.xml but that I can get around by using ant copy to overwrite the package with ready-made package.xml's
    – Marc
    Jan 25, 2013 at 17:58
  • The next issue of sf:deploy not allowing any files in deployRoot which are not specified in package.xml will require another workaroun: I'm thinking of writing a batch file which zips the classes I want to deploy, adds a pre-made package.xml and thus deploys selected, pre-lackaged objects.
    – Marc
    Jan 25, 2013 at 18:00
  • It would be helpful if I could limit a deploy to just what's in the package.xml file, without complaints. Lacking that, scripts that build zipfiles are the next best thing.
    – tggagne
    Dec 18, 2013 at 2:16

OK, the answer to my 2nd question is to use autoUpdatePackage="true". From the documentation p22:

autoUpdatePackage: Optional. Defaults to false. Specifies whether a deploy should continue even if files present in the zip file are not specified in package.xml. Do not use this parameter for deployment to production organizations.

Also, you can have a package.xml which specifies more files than you actually have in your deployRoot or zipFile if you use allowMissingFiles="true". Again the docu:

allowMissingFiles: Optional. Defaults to false. Specifies whether a deploy succeeds even if files that are specified in package.xml are not in the zip file. Do not use this parameter for deployment to production organizations.

The answer too question 3 seems to be No! See p23:

You can deploy any set of components as a package or into your organization directly in the unpackaged package. The package used is not determined by the build.xml target, but by the project manifest (package.xml).

  • :-( Apparently you cannot have more files in your zipFile than are specified in package.xml - The documentation says it works with autoUpdatePackage="true" but it doesn't and generates "Not in package.xml" errors. salesforce.com/us/developer/docs/api_meta/Content/…
    – Marc
    Jan 28, 2013 at 9:16

You can create a simple shell or batch script that generates the package XML file based on the files contained in the folder to deploy. I have set up something like that for running my test classes individually rather than running all tests.

In regards to your second question, I haven't tried changing the name but I am quite positive it should work, at least it should take different package.xml files in different directories.

  • Indeed you need to either have a separate directory or use selective zipping (see above) to create tailor made deployment packages. Would be great if some eclipse guru could explain how to select say 3 classes and pass their name to a batch file... might need to write my own eclipse plugin someday since it seems the force.com IDE is NOT well maintained.
    – Marc
    Jan 25, 2013 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.