chiark / gitweb /
import: get build dir from settings.gradle
authorHans-Christoph Steiner <hans@eds.org>
Tue, 30 Jan 2018 22:07:16 +0000 (23:07 +0100)
committerHans-Christoph Steiner <hans@eds.org>
Mon, 12 Feb 2018 11:05:27 +0000 (12:05 +0100)
Most projects set a single build dir in settings.gradle, so its worth
trying here.

fdroidserver/import.py

index c9526f34f23a419758550419ecdb690fddc9a489..550e7469398d166bcfc0db35b5fec2bf244bb4f3 100644 (file)
@@ -32,6 +32,9 @@ from . import metadata
 from .exception import FDroidException
 
 
+SETTINGS_GRADLE = re.compile('''include\s+['"]:([^'"]*)['"]''')
+
+
 # Get the repo type and address from the given web page. The page is scanned
 # in a rather naive manner for 'git clone xxxx', 'hg clone xxxx', etc, and
 # when one of these is found it's assumed that's the information we want.
@@ -180,6 +183,13 @@ def get_subdir(build_dir):
     if options.subdir:
         return os.path.join(build_dir, options.subdir)
 
+    settings_gradle = os.path.join(build_dir, 'settings.gradle')
+    if os.path.exists(settings_gradle):
+        with open(settings_gradle) as fp:
+            m = SETTINGS_GRADLE.search(fp.read())
+            if m:
+                return os.path.join(build_dir, m.group(1))
+
     return build_dir