8000 Added build-tools version check for ant/gradle selection · ttarfall/python-for-android@dda2332 · GitHub
[go: up one dir, main page]

Skip to content

Commit dda2332

Browse files
committed
Added build-tools version check for ant/gradle selection
1 parent 70bd0d0 commit dda2332

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

pythonforandroid/toolchain.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def check_python_dependencies():
7979
import imp
8080
from appdirs import user_data_dir
8181
import logging
82+
from distutils.version import LooseVersion
8283

8384
from pythonforandroid.recipe import (Recipe, PythonRecipe, CythonRecipe,
8485
CompiledComponentsPythonRecipe,
@@ -771,12 +772,24 @@ def apk(self, args):
771772
build_type = ctx.java_build_tool
772773
if build_type == 'auto':
773774
info('Selecting java build tool:')
774-
if exists('gradlew'):
775+
776+
build_tools_versions = os.listdir(join(ctx.sdk_dir, 'build-tools'))
777+
build_tools_versions = sorted(build_tools_versions,
778+
key=LooseVersion)
779+
build_tools_version = build_tools_versions[-1]
780+
info(('Detected highest available build tools '
781+
'version to be {}').format(build_tools_version))
782+
783+
if build_tools_version >= '25.0' and exists('gradlew'):
775784
build_type = 'gradle'
776785
info(' Building with gradle, as gradle executable is present')
777786
else:
778787
build_type = 'ant'
779-
info(' Building with ant, as no gradle executable detected')
788+
if build_tools_version < '25.0':
789+
info((' Building with ant, as the highest '
790+
'build-tools-version is only {}').format(build_tools_version))
791+
else:
792+
info(' Building with ant, as no gradle executable detected')
780793

781794
if build_type == 'gradle':
782795
# gradle-based build

0 commit comments

Comments
 (0)
0