Deploy code with phing

364 views Asked by At

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?

2

There are 2 answers

0
Anton_Sh On

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

<exec command="rsync -a --delete --exclude '.git' --exclude '.svn' ${gitDir} ${libDir}" checkreturn="true" />
0
Steve E. On

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