chiark / gitweb /
Merge branch 'java-home-lookup' into 'master'
[fdroidserver.git] / fdroidserver / common.py
index 9f7e6c1ba37572626cd1cda8796fd23c23955037..593bab2da947abc1686dbea301066fc5a10c3754 100644 (file)
@@ -59,7 +59,7 @@ default_config = {
         'r10e': None,
         'r12b': "$ANDROID_NDK",
     },
-    'build_tools': "24.0.0",
+    'build_tools': "24.0.1",
     'force_build_tools': False,
     'java_paths': None,
     'ant': "ant",
@@ -136,7 +136,7 @@ def fill_config_defaults(thisconfig):
         pathlist += glob.glob('/System/Library/Java/JavaVirtualMachines/1.[6-9].0.jdk')
         pathlist += glob.glob('/Library/Java/JavaVirtualMachines/*jdk*[6-9]*')
         if os.getenv('JAVA_HOME') is not None:
-            pathlist += os.getenv('JAVA_HOME')
+            pathlist.append(os.getenv('JAVA_HOME'))
         if os.getenv('PROGRAMFILES') is not None:
             pathlist += glob.glob(os.path.join(os.getenv('PROGRAMFILES'), 'Java', 'jdk1.[6-9].*'))
         for d in sorted(pathlist):
@@ -159,11 +159,9 @@ def fill_config_defaults(thisconfig):
                 m = re.match(regex, j)
                 if not m:
                     continue
-                osxhome = os.path.join(d, 'Contents', 'Home')
-                if os.path.exists(osxhome):
-                    thisconfig['java_paths'][m.group(1)] = osxhome
-                else:
-                    thisconfig['java_paths'][m.group(1)] = d
+                for p in [d, os.path.join(d, 'Contents', 'Home')]:
+                    if os.path.exists(os.path.join(p, 'bin', 'javac')):
+                        thisconfig['java_paths'][m.group(1)] = p
 
     for java_version in ('7', '8', '9'):
         if java_version not in thisconfig['java_paths']:
@@ -1373,12 +1371,11 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
             props += "sdk.dir=%s\n" % config['sdk_path']
             props += "sdk-location=%s\n" % config['sdk_path']
         ndk_path = build.ndk_path()
-        # if it wasn't expanded correctly (because the NDK is not
-        # installed or $ANDROID_NDK not set properly), don't insert it.
-        # even if not actually used, Gradle will error with a cryptic
-        # message.
+        # if for any reason the path isn't valid or the directory
+        # doesn't exist, some versions of Gradle will error with a
+        # cryptic message (even if the NDK is not even necessary).
         # https://gitlab.com/fdroid/fdroidserver/issues/171
-        if ndk_path and ndk_path[0] != '$':
+        if ndk_path and os.path.exists(ndk_path):
             # Add ndk location
             props += "ndk.dir=%s\n" % ndk_path
             props += "ndk-location=%s\n" % ndk_path