-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract exclude rules to separate files, abstract away from Gradle. #51
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,27 @@ function property { | |
grep "^${1}=" $PROJECT_DIR/local.properties | cut -d'=' -f2 | ||
} | ||
|
||
function readExcludesFile { | ||
if [ -f "$1" ]; then | ||
EXCLUDES="" | ||
|
||
# Second part is a fallback in case if last line does not contain newline character. | ||
while read -r line || [[ -n "$line" ]] | ||
do | ||
# Do not process empty lines. | ||
if [ ! -z "$line" ]; then | ||
EXCLUDES+="--exclude=\"$line\" " | ||
fi | ||
done < "$1" | ||
|
||
echo "$EXCLUDES" | ||
else | ||
echo "" | ||
fi | ||
} | ||
|
||
pushd "$PROJECT_DIR" | ||
|
||
# Read config variables from local.properties. | ||
REMOTE_BUILD_MACHINE=$(property 'remote_build.machine') | ||
LOCAL_COMPRESS_LEVEL=$(property 'remote_build.local_gzip_level') | ||
|
@@ -40,32 +61,21 @@ if [ -z "$BUILD_COMMAND" ]; then | |
exit 1 | ||
fi | ||
|
||
pushd "$PROJECT_DIR" | ||
# Read exclude rules. | ||
LOCAL_EXCLUDE="$(readExcludesFile .mainframerignorelocal)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about that. What about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #54. I'd vote for current names at the moment and then if we decide to move configs into a separate folder -> rename this files, names are not the point of this PR. |
||
REMOTE_EXCLUDE="$(readExcludesFile .mainframerignoreremote)" | ||
|
||
# Sync project to remote machine. | ||
rsync --archive --delete --compress-level=$LOCAL_COMPRESS_LEVEL \ | ||
--exclude='.gradle' \ | ||
--exclude='.idea' \ | ||
--exclude='**/.git/' \ | ||
--exclude='artifacts' \ | ||
--exclude='captures' \ | ||
--exclude='**/build' \ | ||
--exclude='**/local.properties' \ | ||
--rsh "ssh" ./ "$REMOTE_BUILD_MACHINE:~/$PROJECT_DIR_NAME" | ||
eval "rsync --archive --delete --compress-level=$LOCAL_COMPRESS_LEVEL $LOCAL_EXCLUDE --rsh ssh ./ $REMOTE_BUILD_MACHINE:~/$PROJECT_DIR_NAME" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At this point we can make this a function with four arguments. Not sure if it’s worth it though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for now |
||
|
||
# Build project on a remote machine. | ||
ssh $REMOTE_BUILD_MACHINE "echo 'set -xe && cd ~/$PROJECT_DIR_NAME/ && $BUILD_COMMAND' | bash" | ||
|
||
# Sync project back to local machine. | ||
rsync --archive --delete --compress-level=$REMOTE_COMPRESS_LEVEL \ | ||
--exclude='.gradle' \ | ||
--exclude='.idea' \ | ||
--exclude='**/.git/' \ | ||
--exclude='artifacts' \ | ||
--exclude='captures' \ | ||
--exclude='**/local.properties' \ | ||
--rsh "ssh" "$REMOTE_BUILD_MACHINE:~/$PROJECT_DIR_NAME/" ./ | ||
popd | ||
eval "rsync --archive --delete --compress-level=$REMOTE_COMPRESS_LEVEL $REMOTE_EXCLUDE --rsh ssh $REMOTE_BUILD_MACHINE:~/$PROJECT_DIR_NAME/ ./" | ||
|
||
BUILD_END_TIME=`date +%s` | ||
echo "End time: $( date )" | ||
echo "Whole process took `expr $BUILD_END_TIME - $BUILD_START_TIME` seconds." | ||
|
||
popd |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.gradle | ||
.idea | ||
**/.git/ | ||
**/local.properties | ||
**/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.gradle | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Samples don’t entirely repeat what we have at this point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, it's basic There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do in a separate pr. |
||
.idea | ||
**/.git/ | ||
**/local.properties | ||
**/src/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
remote_build.machine=sample-remote-build-machine.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What’s wrong with
rsync --exclude-from
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing, will try