diff --git a/fdroidserver/common.py b/fdroidserver/common.py
index 946c0de1..d94c995b 100644
--- a/fdroidserver/common.py
+++ b/fdroidserver/common.py
@@ -81,6 +81,7 @@ FDROID_PACKAGE_NAME_REGEX = re.compile(r'''^[a-f0-9]+$''', re.IGNORECASE)
STRICT_APPLICATION_ID_REGEX = re.compile(r'''(?:^[a-zA-Z]+(?:\d*[a-zA-Z_]*)*)(?:\.[a-zA-Z]+(?:\d*[a-zA-Z_]*)*)+$''')
VALID_APPLICATION_ID_REGEX = re.compile(r'''(?:^[a-z_]+(?:\d*[a-zA-Z_]*)*)(?:\.[a-z_]+(?:\d*[a-zA-Z_]*)*)*$''',
re.IGNORECASE)
+ANDROID_PLUGIN_REGEX = re.compile(r'''\s*(:?apply plugin:|id)\(?\s*['"](android|com\.android\.application)['"]\s*\)?''')
MAX_VERSION_CODE = 0x7fffffff # Java's Integer.MAX_VALUE (2147483647)
@@ -1421,6 +1422,7 @@ def parse_androidmanifests(paths, app):
if has_extension(path, 'gradle'):
with open(path, 'r') as f:
+ android_plugin_file = False
inside_flavour_group = 0
inside_required_flavour = 0
for line in f:
@@ -1496,6 +1498,17 @@ def parse_androidmanifests(paths, app):
matches = vcsearch_g(line)
if matches:
vercode = matches.group(1)
+ if not android_plugin_file and ANDROID_PLUGIN_REGEX.match(line):
+ android_plugin_file = True
+ if android_plugin_file:
+ if package:
+ max_package = package
+ if version:
+ max_version = version
+ if vercode:
+ max_vercode = vercode
+ if max_package and max_version and max_vercode:
+ break
else:
try:
xml = parse_xml(path)
diff --git a/fdroidserver/import.py b/fdroidserver/import.py
index a7dfaa49..1fbf9a5f 100644
--- a/fdroidserver/import.py
+++ b/fdroidserver/import.py
@@ -41,7 +41,6 @@ from .exception import FDroidException
SETTINGS_GRADLE = re.compile(r'settings\.gradle(?:\.kts)?')
GRADLE_SUBPROJECT = re.compile(r'''['"]:([^'"]+)['"]''')
-ANDROID_PLUGIN = re.compile(r'''\s*(:?apply plugin:|id)\(?\s*['"](android|com\.android\.application)['"]\s*\)?''')
# Get the repo type and address from the given web page. The page is scanned
@@ -197,7 +196,7 @@ def get_gradle_subdir(build_dir, paths):
line = fp.readline()
if not line:
break
- if ANDROID_PLUGIN.match(line):
+ if common.ANDROID_PLUGIN_REGEX.match(line):
return os.path.relpath(os.path.dirname(f), build_dir)
if first_gradle_dir and first_gradle_dir != '.':
return first_gradle_dir
diff --git a/tests/common.TestCase b/tests/common.TestCase
index bb4d78a6..e003d161 100755
--- a/tests/common.TestCase
+++ b/tests/common.TestCase
@@ -840,6 +840,27 @@ class CommonTest(unittest.TestCase):
self.assertEqual(('0.6.9', '23', 'cn.wildfirechat.chat'),
fdroidserver.common.parse_androidmanifests(paths, app))
+ app = fdroidserver.metadata.App()
+ app.Repo = 'https://github.com/Integreight/1Sheeld-Android-App'
+ paths = [
+ os.path.join('source-files', 'com.integreight.onesheeld', 'pagerIndicator', 'src', 'main', 'AndroidManifest.xml'),
+ os.path.join('source-files', 'com.integreight.onesheeld', 'pagerIndicator', 'build.gradle'),
+ os.path.join('source-files', 'com.integreight.onesheeld', 'oneSheeld', 'src', 'main', 'AndroidManifest.xml'),
+ os.path.join('source-files', 'com.integreight.onesheeld', 'oneSheeld', 'build.gradle'),
+ os.path.join('source-files', 'com.integreight.onesheeld', 'localeapi', 'src', 'main', 'AndroidManifest.xml'),
+ os.path.join('source-files', 'com.integreight.onesheeld', 'localeapi', 'build.gradle'),
+ os.path.join('source-files', 'com.integreight.onesheeld', 'build.gradle'),
+ os.path.join('source-files', 'com.integreight.onesheeld', 'settings.gradle'),
+ os.path.join('source-files', 'com.integreight.onesheeld', 'quickReturnHeader', 'src', 'main', 'AndroidManifest.xml'),
+ os.path.join('source-files', 'com.integreight.onesheeld', 'quickReturnHeader', 'build.gradle'),
+ os.path.join('source-files', 'com.integreight.onesheeld', 'pullToRefreshlibrary', 'src', 'main', 'AndroidManifest.xml'),
+ os.path.join('source-files', 'com.integreight.onesheeld', 'pullToRefreshlibrary', 'build.gradle'),
+ ]
+ for path in paths:
+ self.assertTrue(os.path.isfile(path))
+ self.assertEqual(('1.9.0', '170521', 'com.integreight.onesheeld'),
+ fdroidserver.common.parse_androidmanifests(paths, app))
+
def test_parse_androidmanifests_ignore(self):
app = fdroidserver.metadata.App()
app.id = 'org.fdroid.fdroid'
diff --git a/tests/scanner.TestCase b/tests/scanner.TestCase
index b8f46af9..6017a999 100755
--- a/tests/scanner.TestCase
+++ b/tests/scanner.TestCase
@@ -29,6 +29,7 @@ class ScannerTest(unittest.TestCase):
source_files = os.path.join(self.basedir, 'source-files')
projects = {
'cn.wildfirechat.chat': 4,
+ 'com.integreight.onesheeld': 11,
'Zillode': 1,
'firebase-suspect': 1,
'org.mozilla.rocket': 3,
diff --git a/tests/source-files/com.integreight.onesheeld/build.gradle b/tests/source-files/com.integreight.onesheeld/build.gradle
new file mode 100644
index 00000000..4aa9de97
--- /dev/null
+++ b/tests/source-files/com.integreight.onesheeld/build.gradle
@@ -0,0 +1,16 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:2.3.2'
+ classpath 'com.google.gms:google-services:3.0.0'
+ }
+}
+
+allprojects {
+ repositories {
+ jcenter()
+ }
+}
diff --git a/tests/source-files/com.integreight.onesheeld/gradle/wrapper/gradle-wrapper.properties b/tests/source-files/com.integreight.onesheeld/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..c88a02a7
--- /dev/null
+++ b/tests/source-files/com.integreight.onesheeld/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Mar 15 14:07:53 EET 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
diff --git a/tests/source-files/com.integreight.onesheeld/localeapi/build.gradle b/tests/source-files/com.integreight.onesheeld/localeapi/build.gradle
new file mode 100644
index 00000000..83e327f8
--- /dev/null
+++ b/tests/source-files/com.integreight.onesheeld/localeapi/build.gradle
@@ -0,0 +1,22 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 25
+ buildToolsVersion "25.0.3"
+
+ defaultConfig {
+ minSdkVersion 9
+ targetSdkVersion 17
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+ }
+ }
+}
+
+dependencies {
+ compile 'com.android.support:support-v4:25.1.0'
+}
diff --git a/tests/source-files/com.integreight.onesheeld/localeapi/src/main/AndroidManifest.xml b/tests/source-files/com.integreight.onesheeld/localeapi/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..3178f4f4
--- /dev/null
+++ b/tests/source-files/com.integreight.onesheeld/localeapi/src/main/AndroidManifest.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/source-files/com.integreight.onesheeld/oneSheeld/build.gradle b/tests/source-files/com.integreight.onesheeld/oneSheeld/build.gradle
new file mode 100644
index 00000000..60559586
--- /dev/null
+++ b/tests/source-files/com.integreight.onesheeld/oneSheeld/build.gradle
@@ -0,0 +1,129 @@
+buildscript {
+ repositories {
+ jcenter()
+ maven { url 'https://maven.fabric.io/public' }
+ }
+
+ dependencies {
+ classpath 'io.fabric.tools:gradle:1.+'
+ }
+}
+apply plugin: 'com.android.application'
+apply plugin: 'io.fabric'
+
+repositories {
+ jcenter()
+ maven { url 'https://maven.fabric.io/public' }
+ maven { url "https://jitpack.io" }
+}
+
+
+android {
+ compileSdkVersion 25
+ buildToolsVersion "25.0.3"
+
+ defaultConfig {
+ applicationId "com.integreight.onesheeld"
+ minSdkVersion 9
+ targetSdkVersion 25
+ versionCode 170521
+ versionName "1.9.0"
+ archivesBaseName = "1Sheeld.v$versionName.$versionCode"
+ buildConfigField "long", "TIMESTAMP", System.currentTimeMillis() + "L"
+ }
+
+ buildTypes.all {
+ ext.enableCrashlytics = isCrashlyticsPropertiesAvailable()
+ }
+
+ buildTypes {
+ debug {
+ versionNameSuffix getWorkingBranchSuffix()
+ minifyEnabled true
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ release {
+ minifyEnabled true
+ debuggable false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+
+ packagingOptions {
+ exclude 'META-INF/LICENSE'
+ exclude 'META-INF/NOTICE'
+ exclude 'META-INF/LICENSE.txt'
+ exclude 'META-INF/NOTICE.txt'
+ }
+
+ lintOptions {
+ abortOnError false
+ }
+
+ useLibrary 'org.apache.http.legacy'
+}
+
+dependencies {
+ compile project(':localeapi')
+ compile project(':pullToRefreshlibrary')
+ compile project(':quickReturnHeader')
+ compile project(':pagerIndicator')
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ compile 'com.android.support:support-v4:25.3.1'
+ compile 'com.facebook.android:facebook-android-sdk:4.5.0'
+ compile 'com.google.android.gms:play-services-analytics:10.0.1'
+ compile 'com.google.android.gms:play-services-location:10.0.1'
+ compile 'com.google.android.gms:play-services-auth:10.0.1'
+ compile 'com.google.android.gms:play-services-vision:10.0.1'
+ compile 'com.loopj.android:android-async-http:1.4.9'
+ compile 'com.snappydb:snappydb-lib:0.5.0'
+ compile 'com.esotericsoftware.kryo:kryo:2.24.0'
+ compile 'com.github.hotchemi:android-rate:0.5.0'
+ compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
+ transitive = true;
+ }
+
+ compile('com.google.android.gms:play-services-identity:10.0.1') {
+ transitive = true;
+ }
+ compile('com.google.api-client:google-api-client-android:1.22.0') {
+ exclude group: 'org.apache.httpcomponents'
+ }
+ compile('com.google.apis:google-api-services-gmail:v1-rev48-1.22.0') {
+ exclude group: 'org.apache.httpcomponents'
+ }
+ compile 'org.twitter4j:twitter4j-core:4.0.4'
+ compile 'org.twitter4j:twitter4j-async:4.0.4'
+ compile 'org.twitter4j:twitter4j-stream:4.0.4'
+ compile 'cz.msebera.android:httpclient:4.4.1.1'
+ compile 'net.sf.supercsv:super-csv:2.4.0'
+ compile 'com.github.amlcurran.showcaseview:library:5.4.3'
+ compile 'com.github.emanzanoaxa:RippleEffect:52ea2a0ab6'
+ compile 'com.drewnoakes:metadata-extractor:2.8.1'
+ compile 'com.integreight.onesheeld:sdk:2.2.0'
+ compile 'com.google.firebase:firebase-core:10.0.1'
+ compile 'com.google.firebase:firebase-messaging:10.0.1'
+}
+
+def isCrashlyticsPropertiesAvailable() {
+ return new File("./oneSheeld/fabric.properties").exists()
+}
+
+def getWorkingBranchSuffix() {
+ def workingBranchSuffix = ""
+ try {
+ def workingBranch = "git --git-dir=${rootDir}/.git --work-tree=${rootDir} rev-parse --abbrev-ref HEAD".execute().text.trim()
+ workingBranchSuffix = (workingBranch != "") ? " - branch:" + workingBranch : ""
+ }
+ catch (all) {
+ }
+ return workingBranchSuffix
+}
+
+def isGoogleServicesFileAvailable() {
+ return new File("./oneSheeld/google-services.json").exists()
+}
+
+if (isGoogleServicesFileAvailable()) {
+ apply plugin: 'com.google.gms.google-services'
+}
\ No newline at end of file
diff --git a/tests/source-files/com.integreight.onesheeld/oneSheeld/src/main/AndroidManifest.xml b/tests/source-files/com.integreight.onesheeld/oneSheeld/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..05350254
--- /dev/null
+++ b/tests/source-files/com.integreight.onesheeld/oneSheeld/src/main/AndroidManifest.xml
@@ -0,0 +1,280 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/source-files/com.integreight.onesheeld/pagerIndicator/build.gradle b/tests/source-files/com.integreight.onesheeld/pagerIndicator/build.gradle
new file mode 100644
index 00000000..254932bd
--- /dev/null
+++ b/tests/source-files/com.integreight.onesheeld/pagerIndicator/build.gradle
@@ -0,0 +1,22 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 25
+ buildToolsVersion "25.0.3"
+
+ defaultConfig {
+ minSdkVersion 9
+ targetSdkVersion 9
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+ }
+ }
+}
+
+dependencies {
+ compile 'com.android.support:support-v4:25.1.0'
+}
diff --git a/tests/source-files/com.integreight.onesheeld/pagerIndicator/src/main/AndroidManifest.xml b/tests/source-files/com.integreight.onesheeld/pagerIndicator/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..4314f1b3
--- /dev/null
+++ b/tests/source-files/com.integreight.onesheeld/pagerIndicator/src/main/AndroidManifest.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/tests/source-files/com.integreight.onesheeld/pullToRefreshlibrary/build.gradle b/tests/source-files/com.integreight.onesheeld/pullToRefreshlibrary/build.gradle
new file mode 100644
index 00000000..7db12afa
--- /dev/null
+++ b/tests/source-files/com.integreight.onesheeld/pullToRefreshlibrary/build.gradle
@@ -0,0 +1,20 @@
+apply plugin: 'com.android.library'
+android {
+ compileSdkVersion 25
+ buildToolsVersion "25.0.3"
+
+ defaultConfig {
+ minSdkVersion 9
+ targetSdkVersion 9
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+ }
+ }
+}
+
+dependencies {
+}
\ No newline at end of file
diff --git a/tests/source-files/com.integreight.onesheeld/pullToRefreshlibrary/src/main/AndroidManifest.xml b/tests/source-files/com.integreight.onesheeld/pullToRefreshlibrary/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..c3db5673
--- /dev/null
+++ b/tests/source-files/com.integreight.onesheeld/pullToRefreshlibrary/src/main/AndroidManifest.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/source-files/com.integreight.onesheeld/quickReturnHeader/build.gradle b/tests/source-files/com.integreight.onesheeld/quickReturnHeader/build.gradle
new file mode 100644
index 00000000..83e327f8
--- /dev/null
+++ b/tests/source-files/com.integreight.onesheeld/quickReturnHeader/build.gradle
@@ -0,0 +1,22 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 25
+ buildToolsVersion "25.0.3"
+
+ defaultConfig {
+ minSdkVersion 9
+ targetSdkVersion 17
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+ }
+ }
+}
+
+dependencies {
+ compile 'com.android.support:support-v4:25.1.0'
+}
diff --git a/tests/source-files/com.integreight.onesheeld/quickReturnHeader/src/main/AndroidManifest.xml b/tests/source-files/com.integreight.onesheeld/quickReturnHeader/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..235aef0b
--- /dev/null
+++ b/tests/source-files/com.integreight.onesheeld/quickReturnHeader/src/main/AndroidManifest.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/source-files/com.integreight.onesheeld/settings.gradle b/tests/source-files/com.integreight.onesheeld/settings.gradle
new file mode 100644
index 00000000..fe8d1fea
--- /dev/null
+++ b/tests/source-files/com.integreight.onesheeld/settings.gradle
@@ -0,0 +1,5 @@
+include ':pagerIndicator'
+include ':pullToRefreshlibrary'
+include ':quickReturnHeader'
+include ':localeapi'
+include ':oneSheeld'