Upgrade the project dir only selectively on install

This commit is contained in:
Tobi Schäfer 2024-05-18 21:49:34 +02:00
parent 7fa9b805d6
commit 7f8c776c57
Signed by: tobi
GPG key ID: 91FAE6FE2EBAC4C8

View file

@ -180,11 +180,11 @@ task processSource(type: Sync) {
} }
task update { task update {
def rsyncArgs = ['--archive', '--exclude', 'backups'] def rsyncArgs = ['--archive', '--filter', '- backups']
def confirm = { def confirm = {
ant.input(message: 'Update this installation?', validargs: 'y,n', addproperty: 'continue') ant.input(message: 'Update this installation?', validargs: 'yes,no', addproperty: 'continue')
return ant.continue == 'y' return ant.continue == 'yes'
} }
onlyIf { confirm() } onlyIf { confirm() }
@ -195,20 +195,29 @@ task update {
mkdir backupDir mkdir backupDir
exec { exec {
// Using rsync instead of a CopyTask because the latter chokes on multi-byte characters // Create a backup with rsync instead of a CopyTask because the latter chokes on multi-byte characters
// See https://github.com/gradle/gradle/issues/789 // See https://github.com/gradle/gradle/issues/789
executable 'rsync' executable 'rsync'
args rsyncArgs args rsyncArgs
args "$projectDir/", backupDir args "$projectDir/", backupDir
} }
print "Created backup of ${projectDir} in ${backupDir}"
} }
doLast { doLast {
exec { exec {
// Using rsync instead of installDist task because it does not overwrite the project directory // Using rsync to selectively update the repo directory
executable 'rsync' executable 'rsync'
args '--delete'
args rsyncArgs args rsyncArgs
args '--exclude', 'bin' args '--filter', '+ bin/***'
args '--filter', '+ docs/***'
args '--filter', '+ extras/***'
args '--filter', '+ launcher.jar'
args '--filter', '+ lib'
args '--filter', '+ *.jar'
args '--filter', '- *'
args "${installDist.destinationDir}/", projectDir args "${installDist.destinationDir}/", projectDir
} }
} }