Remove unwanted files in a more consistent way

This commit is contained in:
Daniel Martí 2015-10-08 12:08:21 +02:00
parent 21117b77d2
commit 75b1c029ac

View file

@ -546,20 +546,33 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
(app['id'], thisbuild['version']), p.output) (app['id'], thisbuild['version']), p.output)
for root, dirs, files in os.walk(build_dir): for root, dirs, files in os.walk(build_dir):
def del_dirs(dl):
for d in dl:
if d in dirs:
shutil.rmtree(os.path.join(root, d))
def del_files(fl):
for f in fl:
if f in files:
os.remove(os.path.join(root, f))
if 'build.gradle' in files:
# Even when running clean, gradle stores task/artifact caches in # Even when running clean, gradle stores task/artifact caches in
# .gradle/ as binary files. To avoid overcomplicating the scanner, # .gradle/ as binary files. To avoid overcomplicating the scanner,
# manually delete them, just like `gradle clean` should have removed # manually delete them, just like `gradle clean` should have removed
# the build/ dirs. # the build/ dirs.
if '.gradle' in dirs: del_dirs(['build', '.gradle', 'gradle'])
shutil.rmtree(os.path.join(root, '.gradle')) del_files(['gradlew', 'gradlew.bat'])
# Don't remove possibly necessary 'gradle' dirs if 'gradlew' is not there
if 'gradlew' in files: if 'pom.xml' in files:
logging.debug("Getting rid of Gradle wrapper stuff in %s" % root) del_dirs(['target'])
os.remove(os.path.join(root, 'gradlew'))
if 'gradlew.bat' in files: if any(f in files for f in ['ant.properties', 'project.properties', 'build.xml']):
os.remove(os.path.join(root, 'gradlew.bat')) del_dirs(['bin', 'gen'])
if 'gradle' in dirs:
shutil.rmtree(os.path.join(root, 'gradle')) if 'jni' in dirs:
del_dirs(['obj'])
if options.skipscan: if options.skipscan:
if thisbuild['scandelete']: if thisbuild['scandelete']: