diff --git a/MANIFEST.in b/MANIFEST.in index 19d3c346..2d4fe372 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -729,6 +729,7 @@ include tests/source-files/com.integreight.onesheeld/pullToRefreshlibrary/src/ma include tests/source-files/com.integreight.onesheeld/quickReturnHeader/build.gradle include tests/source-files/com.integreight.onesheeld/quickReturnHeader/src/main/AndroidManifest.xml include tests/source-files/com.integreight.onesheeld/settings.gradle +include tests/source-files/com.jens.automation2/build.gradle include tests/source-files/com.kunzisoft.testcase/build.gradle include tests/source-files/com.nextcloud.client/build.gradle include tests/source-files/com.nextcloud.client.dev/src/generic/fastlane/metadata/android/en-US/full_description.txt diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 1c2ddf1d..55595798 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1649,7 +1649,7 @@ def parse_androidmanifests(paths, app): temp_version_name = matches.group(2) if inside_flavour_group > 0: - if inside_required_flavour > 0: + if inside_required_flavour > 1: matches = psearch_g(line) if matches: s = matches.group(2) @@ -1678,14 +1678,19 @@ def parse_androidmanifests(paths, app): if matches: vercode = matches.group(1) + if inside_required_flavour > 0: if '{' in line: inside_required_flavour += 1 if '}' in line: inside_required_flavour -= 1 + if inside_required_flavour == 1: + inside_required_flavour -= 1 else: - if flavour and re.match( - r'.*[\'"\s]{flavour}[\'"\s].*'.format(flavour=flavour), line): - inside_required_flavour = 1 + if flavour: + if re.match(r'.*[\'"\s]{flavour}[\'"\s].*\{{.*'.format(flavour=flavour), line): + inside_required_flavour = 2 + elif re.match(r'.*[\'"\s]{flavour}[\'"\s].*'.format(flavour=flavour), line): + inside_required_flavour = 1 if '{' in line: inside_flavour_group += 1 diff --git a/tests/common.TestCase b/tests/common.TestCase index 0f567ad3..38e7dd9b 100755 --- a/tests/common.TestCase +++ b/tests/common.TestCase @@ -1248,6 +1248,19 @@ class CommonTest(unittest.TestCase): self.assertEqual(('2.5.2-fdroid', '73', 'com.github.jameshnsears.quoteunquote'), fdroidserver.common.parse_androidmanifests(paths, app)) + app = fdroidserver.metadata.App() + build = fdroidserver.metadata.Build() + build.gradle = ['fdroidFlavor'] + app['Builds'] = [build] + app.id = 'com.jens.automation2' + paths = [ + os.path.join('source-files', 'com.jens.automation2', 'build.gradle'), + ] + for path in paths: + self.assertTrue(os.path.isfile(path)) + self.assertEqual(('1.6.34-fdroid', '105', 'com.jens.automation2'), + fdroidserver.common.parse_androidmanifests(paths, app)) + def test_get_all_gradle_and_manifests(self): """Test whether the function works with relative and absolute paths""" a = fdroidserver.common.get_all_gradle_and_manifests(Path('source-files/cn.wildfirechat.chat')) diff --git a/tests/source-files/com.jens.automation2/build.gradle b/tests/source-files/com.jens.automation2/build.gradle new file mode 100644 index 00000000..1ed6b0cf --- /dev/null +++ b/tests/source-files/com.jens.automation2/build.gradle @@ -0,0 +1,77 @@ +plugins { + id 'com.android.application' +} + +android { + compileSdkVersion 29 + + defaultConfig { + applicationId "com.jens.automation2" + minSdkVersion 16 + compileSdkVersion 29 + buildToolsVersion '29.0.2' + useLibrary 'org.apache.http.legacy' + versionCode 105 + versionName "1.6.34" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + lintOptions { + checkReleaseBuilds false + abortOnError false + } + + flavorDimensions "version" + + productFlavors + { + googlePlayFlavor + { + dimension "version" +// applicationIdSuffix ".googlePlay" + versionNameSuffix "-googlePlay" + targetSdkVersion 29 + } + + fdroidFlavor + { + dimension "version" +// applicationIdSuffix ".fdroid" + versionNameSuffix "-fdroid" + targetSdkVersion 28 + } + + apkFlavor + { + dimension "version" +// applicationIdSuffix ".apk" + versionNameSuffix "-apk" + targetSdkVersion 28 + } + } +} + +dependencies { + + + + implementation 'com.linkedin.dexmaker:dexmaker:2.25.0' + + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'com.google.android.material:material:1.3.0' + testImplementation 'junit:junit:4.+' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' +}