Supposing you want to deploy only selected classes using ant from the force.com ide to various orgs. This can be tricky because you need to ensure both your package.xml and your payload (either your classes directory or a zipfile) contain exactly the same files.
Is there a neat way to do this by defining set ant targets with wildcards for the files to be included?
Best Answer
First, you need to ensure your
package.xml
contains at least what you are deploying. It may contain more, but not less.UPDATE: It is even easier to do this:
Next, setup an ant target in your
build.xml
which looks something like this:When you run this target you will deploy only Class1.cls and Class2.cls. I also find it useful to place the
username
,password
andserverurl
on the target so that I can use a different ant target for each target org without having to switch out thebuild.properties
file.I use the
zipfile
approach (1) because this allows me to easily and centrally control which files go into the payload. If you wish to use a folder withdeployRoot
you need to make a temporary folder and copy in the files you need:In this example you could setup
package1.xml
to only include the files you want to deploy and it will overwritepackage.xml
when you run this ant target thus makingallowMissingFiles="true"
superfluous.