1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-04 22:40:12 +01:00

gradle: Completely get rid of gradlepluginver

We can support multiple output dirs without having to detect/infer the
plugin version. Much simpler and more robust too.
This commit is contained in:
Daniel Martí 2015-12-24 16:41:39 +01:00
parent 138618937f
commit 5b8d593275
2 changed files with 15 additions and 45 deletions

View File

@ -30,7 +30,6 @@ import time
import json
from ConfigParser import ConfigParser
from argparse import ArgumentParser
from distutils.version import LooseVersion
import logging
import common
@ -785,19 +784,23 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
bconfig.get('app', 'title'),
bconfig.get('app', 'version')))
elif method == 'gradle':
src = None
for apks_dir in [
os.path.join(root_dir, 'build', 'outputs', 'apk'),
os.path.join(root_dir, 'build', 'apk'),
]:
apks = glob.glob(os.path.join(apks_dir, '*-release-unsigned.apk'))
if build.gradlepluginver >= LooseVersion('0.11'):
apks_dir = os.path.join(root_dir, 'build', 'outputs', 'apk')
else:
apks_dir = os.path.join(root_dir, 'build', 'apk')
if len(apks) > 1:
raise BuildException('More than one resulting apks found in %s' % apks_dir,
'\n'.join(apks))
if len(apks) == 1:
src = apks[0]
break
if src is None:
raise BuildException('Failed to find any output apks')
apks = glob.glob(os.path.join(apks_dir, '*-release-unsigned.apk'))
if len(apks) > 1:
raise BuildException('More than one resulting apks found in %s' % apks_dir,
'\n'.join(apks))
if len(apks) < 1:
raise BuildException('Failed to find gradle output in %s' % apks_dir)
src = apks[0]
elif method == 'ant':
stdout_apk = '\n'.join([
line for line in p.output.splitlines() if '.apk' in line])

View File

@ -35,7 +35,6 @@ import hashlib
import socket
import xml.etree.ElementTree as XMLElementTree
from distutils.version import LooseVersion
from zipfile import ZipFile
import metadata
@ -1334,38 +1333,6 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
if build.method() == 'gradle':
flavours = build.gradle
gradlepluginver = None
gradle_dirs = [root_dir]
# Parent dir build.gradle
parent_dir = os.path.normpath(os.path.join(root_dir, '..'))
if parent_dir.startswith(build_dir):
gradle_dirs.append(parent_dir)
for dir_path in gradle_dirs:
if gradlepluginver:
break
if not os.path.isdir(dir_path):
continue
for filename in os.listdir(dir_path):
if not filename.endswith('.gradle'):
continue
path = os.path.join(dir_path, filename)
if not os.path.isfile(path):
continue
for line in file(path):
match = gradle_version_regex.match(line)
if match:
gradlepluginver = match.group(1)
break
if gradlepluginver:
build.gradlepluginver = LooseVersion(gradlepluginver)
else:
logging.warn("Could not fetch the gradle plugin version, defaulting to 0.11")
build.gradlepluginver = LooseVersion('0.11')
if build.target:
n = build.target.split('-')[1]
regsub_file(r'compileSdkVersion[ =]+[0-9]+',