2

I am getting a configured package.xml file from force.com IDE and while using the same package.xml file to deploy changes from another folder ANT is checking all the metadata. I know that the tool works like that but how do I create an ant task which copies only required files to another directory?

  • Can you try with 'allowMissingFiles=true' on your deploy target? Looks like your situation is different from mine. – javanoob Apr 18 '16 at 18:17
  • No it is the same as yours, As I am retrieving everything from a target but I only want to deploy some of the components from it which has been described in package.xml. Allowmissingfiles would work when I have described more components in package.xml than my local directory but here the case is opposite. – apple123 Apr 18 '16 at 18:21
1

Here is a sample piece of code that I wrote and you can extend it further for your needs.

  <!-- Create sub folder called classes -->
    <target name="createClassesFolder">
      <mkdir dir="tempFolder/Classes"/>
    </target>


  <!-- Copy contents of classes folder from source folder -->
    <target name="moveClassesFolder" depends="createClassesFolder">
      <copy todir="ClassesRootFolder/Classes">
        <fileset dir="../src/classes"/>
      </copy>
    </target>

Here is how it works:

  1. To use this code you should have a folder named tempFolder already created.
  2. When you run the target createClassesFolder, it will create a sub folder named classes
  3. Now run the target moveClassesFolder and this will copy all the contents of classes folder from your source folder to the tempFolder created in step 1.

Please note how I used ../src/classes because I am not running these commands from the same directory as src folder but one directory above.

  1. You can also similarly create another target to copy package.xml from source folder to the tempFolder.

With all these steps in place, you should be able to just deploy only classes folder and then don't forget to use allowMissingFiles=true attribute because we are using the same package.xml but deploying only subset of it.

  • Thank you so much for your help. So, If I have classes and few other things to deploy I will have to move everything to the temp folder and make it work that way right? As I will have more than one folder at times and different components as well. Is there any other approach you would suggest to retrieve and deploy using tfs and ant migration tool? – apple123 Apr 18 '16 at 19:41
  • What tool are you using for version control? – javanoob Apr 18 '16 at 19:48
  • TFS - team foundation server. What I want is retrieve the latest changes by any developer to local directory and deploy it using ANT. But in doing there is an issue of getting the only latest changes to local directory instead of whole project folder. So I was trying it the other way that by configuring package.xml from force.com IDE but that gave me this error:Not in package.xml. – apple123 Apr 18 '16 at 20:07
  • I never worked on TFS but I get the problem. Do you run any command to get the changes made by other developers into your local system? If the answer is Yes, you can hook a python script or something to do the clean up of folders for you and after that you can just invoke ant deployUnpackaged target. Let me know. – javanoob Apr 18 '16 at 20:27
  • No no command yet. They get everything from the eclipse IDE tfs plug in and put it in a local directory so I was figuring out a way to deploy the only component the developer wants. – apple123 Apr 18 '16 at 20:30

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.