0

I want to sync files from source folder to public folder with Phing but the problem is when I use

<copy todir="${libDir}">
        <fileset dir="${gitDir}">
            <include name="**"></include>
            <exclude name="public/**"/>
        </fileset>
</copy>

or

<filesync sourcedir="${gitDir}" destinationdir="${libDir}" verbose="true" checksum="true" />

the script doesn't remove the files from ${libDir} which already doesn't exist in ${gitDir}. I don`t want first to remove the hole directory and after that to copy all files. It should works but it will take more time. Do you know how I can sync the folders and remove the nonexistent files?

Anton_Sh
  • 225
  • 1
  • 7
  • 16

2 Answers2

0

I found the decision. I just use linux command for that:

<exec command="rsync -a --delete --exclude '.git' --exclude '.svn' ${gitDir} ${libDir}" checkreturn="true" />
Anton_Sh
  • 225
  • 1
  • 7
  • 16
0

It's easy to slip into using 'exec' everywhere in Phing to use native OS tools.

Phing does have an rsync task this has a 'delete' parameter.

Syncs files or directories using the rsync command. Syncing can be done on the same server or from/to a remote server.

<filesync  
  sourcedir="/var/www/development/project1"
  destinationdir="/var/www/html/project1"
  dryrun="true"
  itemizechanges="true"
  verbose="true"
  checksum="true"
  delete = "true" />

Link to the phing docs FileSyncTask

Steve E.
  • 9,003
  • 6
  • 39
  • 57