Optimized rsync setup for GWT + AWS CDK projects

Originally posted on 2020-11-06

This is a simple hack to make sure you don't move a bunch of unnecessary stuff to your remote instance so you can sync your code faster when using GWT and AWS CDK.

My command looks like this:

rsync -avzP --delete \
           --exclude 'build' \
           --exclude 'war' \
           --exclude 'cdk.out' \
           --exclude '.gradle' \
           source-dir user@ip:dest-dir

This syncs everything, deletes anything that went away (like renamed classes or packages when refactoring), and doesn't include the build, war, cdk.out, and .gradle directories. In my experience those are the directories that are the biggest offenders when it comes to size and file count.