Sign up ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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 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.

share|improve this question
At least part of this appears to be a duplicate of this question here:… – Peter Jan 24 '13 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 '13 at 16:56

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

share|improve this answer
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 '13 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 '13 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 '13 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).

share|improve this answer
:-( 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.… – Marc Jan 28 '13 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.

share|improve this answer
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 IDE is NOT well maintained. – Marc Jan 25 '13 at 18:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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