Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
9dbc6697
Unverified
Commit
9dbc6697
authored
Jun 18, 2019
by
Emmanuel Garcia
Committed by
GitHub
Jun 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Config lib dependencies when using flavors (#34592)" (#34655)
This reverts commit
358b9bd3
.
parent
9d38db42
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
108 deletions
+92
-108
gradle_plugin_bundle_test.dart
dev/devicelab/bin/tasks/gradle_plugin_bundle_test.dart
+12
-54
gradle_plugin_fat_apk_test.dart
dev/devicelab/bin/tasks/gradle_plugin_fat_apk_test.dart
+25
-5
gradle_plugin_light_apk_test.dart
dev/devicelab/bin/tasks/gradle_plugin_light_apk_test.dart
+17
-5
apk_utils.dart
dev/devicelab/lib/framework/apk_utils.dart
+29
-32
flutter.gradle
packages/flutter_tools/gradle/flutter.gradle
+8
-7
gradle.dart
packages/flutter_tools/lib/src/android/gradle.dart
+1
-5
No files found.
dev/devicelab/bin/tasks/gradle_plugin_bundle_test.dart
View file @
9dbc6697
...
...
@@ -7,26 +7,19 @@ import 'dart:async';
import
'package:flutter_devicelab/framework/apk_utils.dart'
;
import
'package:flutter_devicelab/framework/framework.dart'
;
import
'package:flutter_devicelab/framework/utils.dart'
;
import
'package:path/path.dart'
as
path
;
Future
<
void
>
main
()
async
{
await
task
(()
async
{
try
{
await
runP
rojectTest
((
FlutterProject
p
roject
)
async
{
await
runP
luginProjectTest
((
FlutterPluginProject
pluginP
roject
)
async
{
section
(
'App bundle content for task bundleRelease without explicit target platform'
);
await
project
.
runGradleTask
(
'bundleRelease'
);
await
p
luginP
roject
.
runGradleTask
(
'bundleRelease'
);
final
String
releaseBundle
=
path
.
join
(
project
.
rootPath
,
'build'
,
'app'
,
'outputs'
,
'bundle'
,
'release'
,
'app.aab'
,
);
if
(!
pluginProject
.
hasReleaseBundle
)
throw
TaskResult
.
failure
(
'Gradle did not produce a release aab file at:
${pluginProject.releaseBundlePath}
'
);
final
Iterable
<
String
>
bundleFiles
=
await
getFilesInAppBundle
(
releaseBundle
);
final
Iterable
<
String
>
bundleFiles
=
await
pluginProject
.
getFilesInAppBundle
(
pluginProject
.
releaseBundlePath
);
checkItContains
<
String
>(<
String
>[
'base/manifest/AndroidManifest.xml'
,
...
...
@@ -38,51 +31,16 @@ Future<void> main() async {
],
bundleFiles
);
});
await
runProjectTest
((
FlutterProject
project
)
async
{
section
(
'App bundle content using flavors without explicit target platform'
);
// Add a few flavors.
await
project
.
addProductFlavors
(<
String
>
[
'production'
,
'staging'
,
'development'
]);
// Build the production flavor in release mode.
await
project
.
runGradleTask
(
'bundleProductionRelease'
);
final
String
bundlePath
=
path
.
join
(
project
.
rootPath
,
'build'
,
'app'
,
'outputs'
,
'bundle'
,
'productionRelease'
,
'app.aab'
,
);
final
Iterable
<
String
>
bundleFiles
=
await
getFilesInAppBundle
(
bundlePath
);
checkItContains
<
String
>(<
String
>[
'base/manifest/AndroidManifest.xml'
,
'base/dex/classes.dex'
,
'base/lib/arm64-v8a/libapp.so'
,
'base/lib/arm64-v8a/libflutter.so'
,
'base/lib/armeabi-v7a/libapp.so'
,
'base/lib/armeabi-v7a/libflutter.so'
,
],
bundleFiles
);
});
await
runProjectTest
((
FlutterProject
project
)
async
{
await
runPluginProjectTest
((
FlutterPluginProject
pluginProject
)
async
{
section
(
'App bundle content for task bundleRelease with target platform = android-arm'
);
await
project
.
runGradleTask
(
'bundleRelease'
,
await
p
luginP
roject
.
runGradleTask
(
'bundleRelease'
,
options:
<
String
>[
'-Ptarget-platform=android-arm'
]);
final
String
releaseBundle
=
path
.
join
(
project
.
rootPath
,
'build'
,
'app'
,
'outputs'
,
'bundle'
,
'release'
,
'app.aab'
,
);
if
(!
pluginProject
.
hasReleaseBundle
)
throw
TaskResult
.
failure
(
'Gradle did not produce a release aab file at:
${pluginProject.releaseBundlePath}
'
);
final
Iterable
<
String
>
bundleFiles
=
await
getFilesInAppBundle
(
releaseBundle
);
final
Iterable
<
String
>
bundleFiles
=
await
pluginProject
.
getFilesInAppBundle
(
pluginProject
.
releaseBundlePath
);
checkItContains
<
String
>(<
String
>[
'base/manifest/AndroidManifest.xml'
,
...
...
dev/devicelab/bin/tasks/gradle_plugin_fat_apk_test.dart
View file @
9dbc6697
...
...
@@ -17,7 +17,11 @@ Future<void> main() async {
section
(
'APK content for task assembleDebug without explicit target platform'
);
await
pluginProject
.
runGradleTask
(
'assembleDebug'
);
final
Iterable
<
String
>
apkFiles
=
await
getFilesInApk
(
pluginProject
.
debugApkPath
);
if
(!
pluginProject
.
hasDebugApk
)
throw
TaskResult
.
failure
(
'Gradle did not produce a debug apk file at:
${pluginProject.debugApkPath}
'
);
final
Iterable
<
String
>
apkFiles
=
await
pluginProject
.
getFilesInApk
(
pluginProject
.
debugApkPath
);
checkItContains
<
String
>(<
String
>[
'AndroidManifest.xml'
,
...
...
@@ -44,7 +48,11 @@ Future<void> main() async {
section
(
'APK content for task assembleRelease without explicit target platform'
);
await
pluginProject
.
runGradleTask
(
'assembleRelease'
);
final
Iterable
<
String
>
apkFiles
=
await
getFilesInApk
(
pluginProject
.
releaseApkPath
);
if
(!
pluginProject
.
hasReleaseApk
)
throw
TaskResult
.
failure
(
'Gradle did not produce a release apk file at:
${pluginProject.releaseApkPath}
'
);
final
Iterable
<
String
>
apkFiles
=
await
pluginProject
.
getFilesInApk
(
pluginProject
.
releaseApkPath
);
checkItContains
<
String
>(<
String
>[
'AndroidManifest.xml'
,
...
...
@@ -67,7 +75,11 @@ Future<void> main() async {
await
pluginProject
.
runGradleTask
(
'assembleRelease'
,
options:
<
String
>[
'-Ptarget-platform=android-arm,android-arm64'
]);
final
Iterable
<
String
>
apkFiles
=
await
getFilesInApk
(
pluginProject
.
releaseApkPath
);
if
(!
pluginProject
.
hasReleaseApk
)
throw
TaskResult
.
failure
(
'Gradle did not produce a release apk at:
${pluginProject.releaseApkPath}
'
);
final
Iterable
<
String
>
apkFiles
=
await
pluginProject
.
getFilesInApk
(
pluginProject
.
releaseApkPath
);
checkItContains
<
String
>(<
String
>[
'AndroidManifest.xml'
,
...
...
@@ -91,7 +103,11 @@ Future<void> main() async {
await
pluginProject
.
runGradleTask
(
'assembleRelease'
,
options:
<
String
>[
'-Ptarget-platform=android-arm,android-arm64'
,
'-Psplit-per-abi=true'
]);
final
Iterable
<
String
>
armApkFiles
=
await
getFilesInApk
(
pluginProject
.
releaseArmApkPath
);
if
(!
pluginProject
.
hasReleaseArmApk
)
throw
TaskResult
.
failure
(
'Gradle did not produce a release apk at:
${pluginProject.releaseArmApkPath}
'
);
final
Iterable
<
String
>
armApkFiles
=
await
pluginProject
.
getFilesInApk
(
pluginProject
.
releaseArmApkPath
);
checkItContains
<
String
>(<
String
>[
'AndroidManifest.xml'
,
...
...
@@ -106,7 +122,11 @@ Future<void> main() async {
'assets/flutter_assets/vm_snapshot_data'
,
],
armApkFiles
);
final
Iterable
<
String
>
arm64ApkFiles
=
await
getFilesInApk
(
pluginProject
.
releaseArm64ApkPath
);
if
(!
pluginProject
.
hasReleaseArm64Apk
)
throw
TaskResult
.
failure
(
'Gradle did not produce a release apk at:
${pluginProject.releaseArm64ApkPath}
'
);
final
Iterable
<
String
>
arm64ApkFiles
=
await
pluginProject
.
getFilesInApk
(
pluginProject
.
releaseArm64ApkPath
);
checkItContains
<
String
>(<
String
>[
'AndroidManifest.xml'
,
...
...
dev/devicelab/bin/tasks/gradle_plugin_light_apk_test.dart
View file @
9dbc6697
...
...
@@ -17,7 +17,11 @@ Future<void> main() async {
await
pluginProject
.
runGradleTask
(
'assembleDebug'
,
options:
<
String
>[
'-Ptarget-platform=android-arm'
]);
final
Iterable
<
String
>
apkFiles
=
await
getFilesInApk
(
pluginProject
.
debugApkPath
);
if
(!
pluginProject
.
hasDebugApk
)
throw
TaskResult
.
failure
(
'Gradle did not produce a debug apk file at:
${pluginProject.debugApkPath}
'
);
final
Iterable
<
String
>
apkFiles
=
await
pluginProject
.
getFilesInApk
(
pluginProject
.
debugApkPath
);
checkItContains
<
String
>(<
String
>[
'AndroidManifest.xml'
,
...
...
@@ -43,7 +47,11 @@ Future<void> main() async {
await
pluginProject
.
runGradleTask
(
'assembleRelease'
,
options:
<
String
>[
'-Ptarget-platform=android-arm'
]);
final
Iterable
<
String
>
apkFiles
=
await
getFilesInApk
(
pluginProject
.
releaseApkPath
);
if
(!
pluginProject
.
hasReleaseApk
)
throw
TaskResult
.
failure
(
'Gradle did not produce a release apk file at:
${pluginProject.releaseApkPath}
'
);
final
Iterable
<
String
>
apkFiles
=
await
pluginProject
.
getFilesInApk
(
pluginProject
.
releaseApkPath
);
checkItContains
<
String
>(<
String
>[
'AndroidManifest.xml'
,
...
...
@@ -66,7 +74,11 @@ Future<void> main() async {
await
pluginProject
.
runGradleTask
(
'assembleRelease'
,
options:
<
String
>[
'-Ptarget-platform=android-arm64'
]);
final
Iterable
<
String
>
apkFiles
=
await
getFilesInApk
(
pluginProject
.
releaseApkPath
);
if
(!
pluginProject
.
hasReleaseApk
)
throw
TaskResult
.
failure
(
'Gradle did not produce a release apk file at:
${pluginProject.releaseApkPath}
'
);
final
Iterable
<
String
>
apkFiles
=
await
pluginProject
.
getFilesInApk
(
pluginProject
.
releaseApkPath
);
checkItContains
<
String
>(<
String
>[
'AndroidManifest.xml'
,
...
...
@@ -112,7 +124,7 @@ Future<void> main() async {
await
runProjectTest
((
FlutterProject
project
)
async
{
section
(
'gradlew assembleFreeDebug (product flavor)'
);
await
project
.
addProductFlavor
s
(<
String
>[
'free'
]
);
await
project
.
addProductFlavor
(
'free'
);
await
project
.
runGradleTask
(
'assembleFreeDebug'
);
});
...
...
@@ -157,7 +169,7 @@ Future<void> main() async {
await
runPluginProjectTest
((
FlutterPluginProject
pluginProject
)
async
{
section
(
'gradlew assembleDebug on plugin example'
);
await
pluginProject
.
runGradleTask
(
'assembleDebug'
);
if
(!
File
(
pluginProject
.
debugApkPath
).
existsSync
()
)
if
(!
pluginProject
.
hasDebugApk
)
throw
TaskResult
.
failure
(
'Gradle did not produce an apk file at the expected place'
);
});
...
...
dev/devicelab/lib/framework/apk_utils.dart
View file @
9dbc6697
...
...
@@ -34,27 +34,6 @@ Future<void> runPluginProjectTest(Future<void> testFunction(FlutterPluginProject
}
}
Future
<
Iterable
<
String
>>
getFilesInApk
(
String
apk
)
async
{
if
(!
File
(
apk
).
existsSync
())
throw
TaskResult
.
failure
(
'Gradle did not produce an output artifact file at:
$apk
'
);
final
Process
unzip
=
await
startProcess
(
'unzip'
,
<
String
>[
'-v'
,
apk
],
isBot:
false
,
// we just want to test the output, not have any debugging info
);
return
unzip
.
stdout
.
transform
(
utf8
.
decoder
)
.
transform
(
const
LineSplitter
())
.
map
((
String
line
)
=>
line
.
split
(
' '
).
last
)
.
toList
();
}
Future
<
Iterable
<
String
>>
getFilesInAppBundle
(
String
bundle
)
{
return
getFilesInApk
(
bundle
);
}
void
checkItContains
<
T
>(
Iterable
<
T
>
values
,
Iterable
<
T
>
collection
)
{
for
(
T
value
in
values
)
{
if
(!
collection
.
contains
(
value
))
{
...
...
@@ -116,25 +95,20 @@ android {
'''
);
}
Future
<
void
>
addProductFlavor
s
(
Iterable
<
String
>
flavors
)
async
{
Future
<
void
>
addProductFlavor
(
String
name
)
async
{
final
File
buildScript
=
File
(
path
.
join
(
androidPath
,
'app'
,
'build.gradle'
),
);
final
String
flavorConfig
=
flavors
.
map
((
String
name
)
{
return
'''
$name
{
applicationIdSuffix ".
$name
"
versionNameSuffix "-
$name
"
}
'''
;
}).
join
(
'
\n
'
);
buildScript
.
openWrite
(
mode:
FileMode
.
append
).
write
(
'''
android {
flavorDimensions "mode"
productFlavors {
$flavorConfig
$name
{
applicationIdSuffix ".
$name
"
versionNameSuffix "-
$name
"
}
}
}
'''
);
...
...
@@ -186,9 +160,32 @@ class FlutterPluginProject {
String
get
releaseArm64ApkPath
=>
path
.
join
(
examplePath
,
'build'
,
'app'
,
'outputs'
,
'apk'
,
'release'
,
'app-arm64-v8a-release.apk'
);
String
get
releaseBundlePath
=>
path
.
join
(
examplePath
,
'build'
,
'app'
,
'outputs'
,
'bundle'
,
'release'
,
'app.aab'
);
bool
get
hasDebugApk
=>
File
(
debugApkPath
).
existsSync
();
bool
get
hasReleaseApk
=>
File
(
releaseApkPath
).
existsSync
();
bool
get
hasReleaseArmApk
=>
File
(
releaseArmApkPath
).
existsSync
();
bool
get
hasReleaseArm64Apk
=>
File
(
releaseArm64ApkPath
).
existsSync
();
bool
get
hasReleaseBundle
=>
File
(
releaseBundlePath
).
existsSync
();
Future
<
void
>
runGradleTask
(
String
task
,
{
List
<
String
>
options
})
async
{
return
_runGradleTask
(
workingDirectory:
exampleAndroidPath
,
task:
task
,
options:
options
);
}
Future
<
Iterable
<
String
>>
getFilesInApk
(
String
apk
)
async
{
final
Process
unzip
=
await
startProcess
(
'unzip'
,
<
String
>[
'-v'
,
apk
],
isBot:
false
,
// we just want to test the output, not have any debugging info
);
return
unzip
.
stdout
.
transform
(
utf8
.
decoder
)
.
transform
(
const
LineSplitter
())
.
map
((
String
line
)
=>
line
.
split
(
' '
).
last
)
.
toList
();
}
Future
<
Iterable
<
String
>>
getFilesInAppBundle
(
String
bundle
)
{
return
getFilesInApk
(
bundle
);
}
}
Future
<
void
>
_runGradleTask
({
String
workingDirectory
,
String
task
,
List
<
String
>
options
})
async
{
...
...
packages/flutter_tools/gradle/flutter.gradle
View file @
9dbc6697
...
...
@@ -114,6 +114,7 @@ class FlutterPlugin implements Plugin<Project> {
String
abiValue
=
PLATFORM_ARCH_MAP
[
targetArch
]
project
.
android
{
packagingOptions
{
pickFirst
"lib/${abiValue}/libflutter.so"
// Prevent the ELF library from getting corrupted.
doNotStrip
"*/${abiValue}/libapp.so"
}
...
...
@@ -165,7 +166,7 @@ class FlutterPlugin implements Plugin<Project> {
// The local engine is built for one of the build type.
// However, we use the same engine for each of the build types.
project
.
android
.
buildTypes
.
each
{
addApiDependencies
(
project
,
it
.
name
,
project
.
files
{
addApiDependencies
(
project
,
it
,
project
.
files
{
flutterJar
})
}
...
...
@@ -204,13 +205,13 @@ class FlutterPlugin implements Plugin<Project> {
// added after applying the Flutter plugin.
project
.
android
.
buildTypes
.
each
{
def
buildMode
=
buildModeFor
(
it
)
addApiDependencies
(
project
,
it
.
name
,
project
.
files
{
addApiDependencies
(
project
,
it
,
project
.
files
{
baseJar
[
buildMode
]
})
}
project
.
android
.
buildTypes
.
whenObjectAdded
{
def
buildMode
=
buildModeFor
(
it
)
addApiDependencies
(
project
,
it
.
name
,
project
.
files
{
addApiDependencies
(
project
,
it
,
project
.
files
{
baseJar
[
buildMode
]
})
}
...
...
@@ -341,14 +342,14 @@ class FlutterPlugin implements Plugin<Project> {
}
}
private
static
void
addApiDependencies
(
Project
project
,
String
variantNam
e
,
FileCollection
files
)
{
private
static
void
addApiDependencies
(
Project
project
,
buildTyp
e
,
FileCollection
files
)
{
project
.
dependencies
{
String
configuration
;
// `compile` dependencies are now `api` dependencies.
if
(
project
.
getConfigurations
().
findByName
(
"api"
))
{
configuration
=
"${variantName}
Api"
;
configuration
=
buildType
.
name
+
"
Api"
;
}
else
{
configuration
=
"${variantName}
Compile"
;
configuration
=
buildType
.
name
+
"
Compile"
;
}
add
(
configuration
,
files
)
}
...
...
@@ -526,7 +527,7 @@ class FlutterPlugin implements Plugin<Project> {
}
}
// Include the snapshots and libflutter.so in `lib/`.
addApiDependencies
(
project
,
variant
.
nam
e
,
project
.
files
{
addApiDependencies
(
project
,
buildTyp
e
,
project
.
files
{
packFlutterSnapshotsAndLibsTask
})
...
...
packages/flutter_tools/lib/src/android/gradle.dart
View file @
9dbc6697
...
...
@@ -585,12 +585,8 @@ File _findBundleFile(GradleProject project, BuildInfo buildInfo) {
if
(
bundleFile
.
existsSync
())
return
bundleFile
;
if
(
buildInfo
.
flavor
!=
null
)
{
// Android Studio Gradle plugin v3 adds the flavor to the path. For the bundle the folder name is the flavor plus the mode name.
// On linux, filenames are case sensitive.
bundleFile
=
project
.
bundleDirectory
.
childDirectory
(
camelCase
(
'
${buildInfo.flavor}
_
$modeName
'
))
.
childFile
(
bundleFileName
);
bundleFile
=
project
.
bundleDirectory
.
childDirectory
(
buildInfo
.
flavor
+
modeName
).
childFile
(
bundleFileName
);
if
(
bundleFile
.
existsSync
())
return
bundleFile
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment