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
6266d5f3
Unverified
Commit
6266d5f3
authored
Aug 30, 2019
by
Emmanuel Garcia
Committed by
GitHub
Aug 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log flags in build apk and appbundle (#39457)
parent
2dbf0106
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
411 additions
and
122 deletions
+411
-122
android_builder.dart
packages/flutter_tools/lib/src/android/android_builder.dart
+169
-0
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+2
-2
apk.dart
packages/flutter_tools/lib/src/android/apk.dart
+0
-41
app_bundle.dart
packages/flutter_tools/lib/src/android/app_bundle.dart
+0
-49
build_aar.dart
packages/flutter_tools/lib/src/commands/build_aar.dart
+2
-6
build_apk.dart
packages/flutter_tools/lib/src/commands/build_apk.dart
+31
-8
build_appbundle.dart
packages/flutter_tools/lib/src/commands/build_appbundle.dart
+23
-2
usage.dart
packages/flutter_tools/lib/src/reporting/usage.dart
+5
-0
build_aar_test.dart
...ter_tools/test/general.shard/commands/build_aar_test.dart
+4
-14
build_apk_test.dart
...ter_tools/test/general.shard/commands/build_apk_test.dart
+96
-0
build_appbundle_test.dart
...ols/test/general.shard/commands/build_appbundle_test.dart
+79
-0
No files found.
packages/flutter_tools/lib/src/android/a
a
r.dart
→
packages/flutter_tools/lib/src/android/a
ndroid_builde
r.dart
View file @
6266d5f3
...
@@ -7,30 +7,49 @@ import 'dart:async';
...
@@ -7,30 +7,49 @@ import 'dart:async';
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'../base/common.dart'
;
import
'../base/common.dart'
;
import
'../base/context.dart'
;
import
'../build_info.dart'
;
import
'../build_info.dart'
;
import
'../globals.dart'
;
import
'../project.dart'
;
import
'../project.dart'
;
import
'android_sdk.dart'
;
import
'android_sdk.dart'
;
import
'gradle.dart'
;
import
'gradle.dart'
;
/// Provides a method to build a module or plugin as AAR.
/// The builder in the current context.
abstract
class
AarBuilder
{
AndroidBuilder
get
androidBuilder
=>
context
.
get
<
AndroidBuilder
>()
??
_AndroidBuilderImpl
();
/// Builds the AAR artifacts.
Future
<
void
>
build
({
/// Provides the methods to build Android artifacts.
abstract
class
AndroidBuilder
{
/// Builds an AAR artifact.
Future
<
void
>
buildAar
({
@required
FlutterProject
project
,
@required
FlutterProject
project
,
@required
AndroidBuildInfo
androidBuildInfo
,
@required
AndroidBuildInfo
androidBuildInfo
,
@required
String
target
,
@required
String
target
,
@required
String
outputDir
,
@required
String
outputDir
,
});
});
/// Builds an APK artifact.
Future
<
void
>
buildApk
({
@required
FlutterProject
project
,
@required
AndroidBuildInfo
androidBuildInfo
,
@required
String
target
,
});
/// Builds an App Bundle artifact.
Future
<
void
>
buildAab
({
@required
FlutterProject
project
,
@required
AndroidBuildInfo
androidBuildInfo
,
@required
String
target
,
});
}
}
/// Default implementation of [AarBuilder].
/// Default implementation of [AarBuilder].
class
AarBuilderImpl
extends
Aar
Builder
{
class
_AndroidBuilderImpl
extends
Android
Builder
{
Aar
BuilderImpl
();
_Android
BuilderImpl
();
/// Builds the AAR and POM files for the current Flutter module or plugin.
/// Builds the AAR and POM files for the current Flutter module or plugin.
@override
@override
Future
<
void
>
build
({
Future
<
void
>
build
Aar
({
@required
FlutterProject
project
,
@required
FlutterProject
project
,
@required
AndroidBuildInfo
androidBuildInfo
,
@required
AndroidBuildInfo
androidBuildInfo
,
@required
String
target
,
@required
String
target
,
...
@@ -38,7 +57,7 @@ class AarBuilderImpl extends AarBuilder {
...
@@ -38,7 +57,7 @@ class AarBuilderImpl extends AarBuilder {
})
async
{
})
async
{
if
(!
project
.
android
.
isUsingGradle
)
{
if
(!
project
.
android
.
isUsingGradle
)
{
throwToolExit
(
throwToolExit
(
'The build process for Android has changed, and the current project configuration
\n
'
'The build process for Android has changed, and the current project configuration
'
'is no longer valid. Please consult
\n\n
'
'is no longer valid. Please consult
\n\n
'
' https://github.com/flutter/flutter/wiki/Upgrading-Flutter-projects-to-build-with-gradle
\n\n
'
' https://github.com/flutter/flutter/wiki/Upgrading-Flutter-projects-to-build-with-gradle
\n\n
'
'for details on how to upgrade the project.'
'for details on how to upgrade the project.'
...
@@ -59,4 +78,92 @@ class AarBuilderImpl extends AarBuilder {
...
@@ -59,4 +78,92 @@ class AarBuilderImpl extends AarBuilder {
);
);
androidSdk
.
reinitialize
();
androidSdk
.
reinitialize
();
}
}
/// Builds the APK.
@override
Future
<
void
>
buildApk
({
@required
FlutterProject
project
,
@required
AndroidBuildInfo
androidBuildInfo
,
@required
String
target
,
})
async
{
if
(!
project
.
android
.
isUsingGradle
)
{
throwToolExit
(
'The build process for Android has changed, and the current project configuration '
'is no longer valid. Please consult
\n\n
'
' https://github.com/flutter/flutter/wiki/Upgrading-Flutter-projects-to-build-with-gradle
\n\n
'
'for details on how to upgrade the project.'
);
}
// Validate that we can find an android sdk.
if
(
androidSdk
==
null
)
{
throwToolExit
(
'No Android SDK found. Try setting the ANDROID_SDK_ROOT environment variable.'
);
}
await
buildGradleProject
(
project:
project
,
androidBuildInfo:
androidBuildInfo
,
target:
target
,
isBuildingBundle:
false
,
);
androidSdk
.
reinitialize
();
}
/// Builds the App Bundle.
@override
Future
<
void
>
buildAab
({
@required
FlutterProject
project
,
@required
AndroidBuildInfo
androidBuildInfo
,
@required
String
target
,
})
async
{
if
(!
project
.
android
.
isUsingGradle
)
{
throwToolExit
(
'The build process for Android has changed, and the current project configuration '
'is no longer valid. Please consult
\n\n
'
'https://github.com/flutter/flutter/wiki/Upgrading-Flutter-projects-to-build-with-gradle
\n\n
'
'for details on how to upgrade the project.'
);
}
// Validate that we can find an android sdk.
if
(
androidSdk
==
null
)
{
throwToolExit
(
'No Android SDK found. Try setting the ANDROID_HOME environment variable.'
);
}
final
List
<
String
>
validationResult
=
androidSdk
.
validateSdkWellFormed
();
if
(
validationResult
.
isNotEmpty
)
{
for
(
String
message
in
validationResult
)
{
printError
(
message
,
wrap:
false
);
}
throwToolExit
(
'Try re-installing or updating your Android SDK.'
);
}
return
buildGradleProject
(
project:
project
,
androidBuildInfo:
androidBuildInfo
,
target:
target
,
isBuildingBundle:
true
,
);
}
}
/// A fake implementation of [AndroidBuilder].
@visibleForTesting
class
FakeAndroidBuilder
implements
AndroidBuilder
{
@override
Future
<
void
>
buildAar
({
@required
FlutterProject
project
,
@required
AndroidBuildInfo
androidBuildInfo
,
@required
String
target
,
@required
String
outputDir
,
})
async
{}
@override
Future
<
void
>
buildApk
({
@required
FlutterProject
project
,
@required
AndroidBuildInfo
androidBuildInfo
,
@required
String
target
,
})
async
{}
@override
Future
<
void
>
buildAab
({
@required
FlutterProject
project
,
@required
AndroidBuildInfo
androidBuildInfo
,
@required
String
target
,
})
async
{}
}
}
packages/flutter_tools/lib/src/android/android_device.dart
View file @
6266d5f3
...
@@ -6,9 +6,9 @@ import 'dart:async';
...
@@ -6,9 +6,9 @@ import 'dart:async';
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'../android/android_builder.dart'
;
import
'../android/android_sdk.dart'
;
import
'../android/android_sdk.dart'
;
import
'../android/android_workflow.dart'
;
import
'../android/android_workflow.dart'
;
import
'../android/apk.dart'
;
import
'../application_package.dart'
;
import
'../application_package.dart'
;
import
'../base/common.dart'
show
throwToolExit
;
import
'../base/common.dart'
show
throwToolExit
;
import
'../base/file_system.dart'
;
import
'../base/file_system.dart'
;
...
@@ -482,7 +482,7 @@ class AndroidDevice extends Device {
...
@@ -482,7 +482,7 @@ class AndroidDevice extends Device {
if
(!
prebuiltApplication
||
androidSdk
.
licensesAvailable
&&
androidSdk
.
latestVersion
==
null
)
{
if
(!
prebuiltApplication
||
androidSdk
.
licensesAvailable
&&
androidSdk
.
latestVersion
==
null
)
{
printTrace
(
'Building APK'
);
printTrace
(
'Building APK'
);
final
FlutterProject
project
=
FlutterProject
.
current
();
final
FlutterProject
project
=
FlutterProject
.
current
();
await
buildApk
(
await
androidBuilder
.
buildApk
(
project:
project
,
project:
project
,
target:
mainPath
,
target:
mainPath
,
androidBuildInfo:
AndroidBuildInfo
(
debuggingOptions
.
buildInfo
,
androidBuildInfo:
AndroidBuildInfo
(
debuggingOptions
.
buildInfo
,
...
...
packages/flutter_tools/lib/src/android/apk.dart
deleted
100644 → 0
View file @
2dbf0106
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:meta/meta.dart'
;
import
'../base/common.dart'
;
import
'../build_info.dart'
;
import
'../project.dart'
;
import
'android_sdk.dart'
;
import
'gradle.dart'
;
Future
<
void
>
buildApk
({
@required
FlutterProject
project
,
@required
String
target
,
@required
AndroidBuildInfo
androidBuildInfo
,
})
async
{
if
(!
project
.
android
.
isUsingGradle
)
{
throwToolExit
(
'The build process for Android has changed, and the current project configuration
\n
'
'is no longer valid. Please consult
\n\n
'
' https://github.com/flutter/flutter/wiki/Upgrading-Flutter-projects-to-build-with-gradle
\n\n
'
'for details on how to upgrade the project.'
);
}
// Validate that we can find an android sdk.
if
(
androidSdk
==
null
)
throwToolExit
(
'No Android SDK found. Try setting the ANDROID_SDK_ROOT environment variable.'
);
await
buildGradleProject
(
project:
project
,
androidBuildInfo:
androidBuildInfo
,
target:
target
,
isBuildingBundle:
false
,
);
androidSdk
.
reinitialize
();
}
packages/flutter_tools/lib/src/android/app_bundle.dart
deleted
100644 → 0
View file @
2dbf0106
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:meta/meta.dart'
;
import
'../base/common.dart'
;
import
'../build_info.dart'
;
import
'../globals.dart'
;
import
'../project.dart'
;
import
'android_sdk.dart'
;
import
'gradle.dart'
;
Future
<
void
>
buildAppBundle
({
@required
FlutterProject
project
,
@required
String
target
,
@required
AndroidBuildInfo
androidBuildInfo
,
})
async
{
if
(!
project
.
android
.
isUsingGradle
)
{
throwToolExit
(
'The build process for Android has changed, and the current project configuration
\n
'
'is no longer valid. Please consult
\n\n
'
'https://github.com/flutter/flutter/wiki/Upgrading-Flutter-projects-to-build-with-gradle
\n\n
'
'for details on how to upgrade the project.'
);
}
// Validate that we can find an android sdk.
if
(
androidSdk
==
null
)
throwToolExit
(
'No Android SDK found. Try setting the ANDROID_HOME environment variable.'
);
final
List
<
String
>
validationResult
=
androidSdk
.
validateSdkWellFormed
();
if
(
validationResult
.
isNotEmpty
)
{
for
(
String
message
in
validationResult
)
{
printError
(
message
,
wrap:
false
);
}
throwToolExit
(
'Try re-installing or updating your Android SDK.'
);
}
return
buildGradleProject
(
project:
project
,
androidBuildInfo:
androidBuildInfo
,
target:
target
,
isBuildingBundle:
true
,
);
}
packages/flutter_tools/lib/src/commands/build_aar.dart
View file @
6266d5f3
...
@@ -4,8 +4,7 @@
...
@@ -4,8 +4,7 @@
import
'dart:async'
;
import
'dart:async'
;
import
'../android/aar.dart'
;
import
'../android/android_builder.dart'
;
import
'../base/context.dart'
;
import
'../base/os.dart'
;
import
'../base/os.dart'
;
import
'../build_info.dart'
;
import
'../build_info.dart'
;
import
'../project.dart'
;
import
'../project.dart'
;
...
@@ -13,9 +12,6 @@ import '../reporting/reporting.dart';
...
@@ -13,9 +12,6 @@ import '../reporting/reporting.dart';
import
'../runner/flutter_command.dart'
show
DevelopmentArtifact
,
FlutterCommandResult
;
import
'../runner/flutter_command.dart'
show
DevelopmentArtifact
,
FlutterCommandResult
;
import
'build.dart'
;
import
'build.dart'
;
/// The AAR builder in the current context.
AarBuilder
get
aarBuilder
=>
context
.
get
<
AarBuilder
>()
??
AarBuilderImpl
();
class
BuildAarCommand
extends
BuildSubCommand
{
class
BuildAarCommand
extends
BuildSubCommand
{
BuildAarCommand
({
bool
verboseHelp
=
false
})
{
BuildAarCommand
({
bool
verboseHelp
=
false
})
{
addBuildModeFlags
(
verboseHelp:
verboseHelp
);
addBuildModeFlags
(
verboseHelp:
verboseHelp
);
...
@@ -74,7 +70,7 @@ class BuildAarCommand extends BuildSubCommand {
...
@@ -74,7 +70,7 @@ class BuildAarCommand extends BuildSubCommand {
final
AndroidBuildInfo
androidBuildInfo
=
AndroidBuildInfo
(
buildInfo
,
final
AndroidBuildInfo
androidBuildInfo
=
AndroidBuildInfo
(
buildInfo
,
targetArchs:
argResults
[
'target-platform'
].
map
<
AndroidArch
>(
getAndroidArchForName
));
targetArchs:
argResults
[
'target-platform'
].
map
<
AndroidArch
>(
getAndroidArchForName
));
await
a
arBuilder
.
build
(
await
a
ndroidBuilder
.
buildAar
(
project:
_getProject
(),
project:
_getProject
(),
target:
''
,
// Not needed because this command only builds Android's code.
target:
''
,
// Not needed because this command only builds Android's code.
androidBuildInfo:
androidBuildInfo
,
androidBuildInfo:
androidBuildInfo
,
...
...
packages/flutter_tools/lib/src/commands/build_apk.dart
View file @
6266d5f3
...
@@ -4,11 +4,12 @@
...
@@ -4,11 +4,12 @@
import
'dart:async'
;
import
'dart:async'
;
import
'../android/a
pk
.dart'
;
import
'../android/a
ndroid_builder
.dart'
;
import
'../base/terminal.dart'
;
import
'../base/terminal.dart'
;
import
'../build_info.dart'
;
import
'../build_info.dart'
;
import
'../globals.dart'
;
import
'../globals.dart'
;
import
'../project.dart'
;
import
'../project.dart'
;
import
'../reporting/reporting.dart'
;
import
'../runner/flutter_command.dart'
show
DevelopmentArtifact
,
FlutterCommandResult
;
import
'../runner/flutter_command.dart'
show
DevelopmentArtifact
,
FlutterCommandResult
;
import
'build.dart'
;
import
'build.dart'
;
...
@@ -39,18 +40,40 @@ class BuildApkCommand extends BuildSubCommand {
...
@@ -39,18 +40,40 @@ class BuildApkCommand extends BuildSubCommand {
@override
@override
final
String
name
=
'apk'
;
final
String
name
=
'apk'
;
@override
Future
<
Set
<
DevelopmentArtifact
>>
get
requiredArtifacts
async
=>
const
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
universal
,
DevelopmentArtifact
.
android
,
};
@override
@override
final
String
description
=
'Build an Android APK file from your app.
\n\n
'
final
String
description
=
'Build an Android APK file from your app.
\n\n
'
'This command can build debug and release versions of your application.
\'
debug
\'
builds support '
'This command can build debug and release versions of your application.
\'
debug
\'
builds support '
'debugging and a quick development cycle.
\'
release
\'
builds don
\'
t support debugging and are '
'debugging and a quick development cycle.
\'
release
\'
builds don
\'
t support debugging and are '
'suitable for deploying to app stores.'
;
'suitable for deploying to app stores.'
;
@override
Future
<
Map
<
CustomDimensions
,
String
>>
get
usageValues
async
{
final
Map
<
CustomDimensions
,
String
>
usage
=
<
CustomDimensions
,
String
>{};
usage
[
CustomDimensions
.
commandBuildApkTargetPlatform
]
=
(
argResults
[
'target-platform'
]
as
List
<
String
>).
join
(
','
);
usage
[
CustomDimensions
.
commandBuildApkSplitPerAbi
]
=
argResults
[
'split-per-abi'
].
toString
();
if
(
argResults
[
'release'
])
{
usage
[
CustomDimensions
.
commandBuildApkBuildMode
]
=
'release'
;
}
else
if
(
argResults
[
'debug'
])
{
usage
[
CustomDimensions
.
commandBuildApkBuildMode
]
=
'debug'
;
}
else
if
(
argResults
[
'profile'
])
{
usage
[
CustomDimensions
.
commandBuildApkBuildMode
]
=
'profile'
;
}
else
{
// The build defaults to release.
usage
[
CustomDimensions
.
commandBuildApkBuildMode
]
=
'release'
;
}
return
usage
;
}
@override
Future
<
Set
<
DevelopmentArtifact
>>
get
requiredArtifacts
async
=>
const
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
universal
,
DevelopmentArtifact
.
android
,
};
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
final
BuildInfo
buildInfo
=
getBuildInfo
();
final
BuildInfo
buildInfo
=
getBuildInfo
();
...
@@ -76,7 +99,7 @@ class BuildApkCommand extends BuildSubCommand {
...
@@ -76,7 +99,7 @@ class BuildApkCommand extends BuildSubCommand {
'--split-per-abi'
,
indent:
8
);
'--split-per-abi'
,
indent:
8
);
printStatus
(
'Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split'
,
indent:
8
);
printStatus
(
'Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split'
,
indent:
8
);
}
}
await
buildApk
(
await
androidBuilder
.
buildApk
(
project:
FlutterProject
.
current
(),
project:
FlutterProject
.
current
(),
target:
targetFile
,
target:
targetFile
,
androidBuildInfo:
androidBuildInfo
,
androidBuildInfo:
androidBuildInfo
,
...
...
packages/flutter_tools/lib/src/commands/build_appbundle.dart
View file @
6266d5f3
...
@@ -4,9 +4,10 @@
...
@@ -4,9 +4,10 @@
import
'dart:async'
;
import
'dart:async'
;
import
'../android/a
pp_bundle
.dart'
;
import
'../android/a
ndroid_builder
.dart'
;
import
'../build_info.dart'
;
import
'../build_info.dart'
;
import
'../project.dart'
;
import
'../project.dart'
;
import
'../reporting/reporting.dart'
;
import
'../runner/flutter_command.dart'
show
FlutterCommandResult
;
import
'../runner/flutter_command.dart'
show
FlutterCommandResult
;
import
'build.dart'
;
import
'build.dart'
;
...
@@ -39,12 +40,32 @@ class BuildAppBundleCommand extends BuildSubCommand {
...
@@ -39,12 +40,32 @@ class BuildAppBundleCommand extends BuildSubCommand {
'debugging and a quick development cycle.
\'
release
\'
builds don
\'
t support debugging and are '
'debugging and a quick development cycle.
\'
release
\'
builds don
\'
t support debugging and are '
'suitable for deploying to app stores.
\n
app bundle improves your app size'
;
'suitable for deploying to app stores.
\n
app bundle improves your app size'
;
@override
Future
<
Map
<
CustomDimensions
,
String
>>
get
usageValues
async
{
final
Map
<
CustomDimensions
,
String
>
usage
=
<
CustomDimensions
,
String
>{};
usage
[
CustomDimensions
.
commandBuildAppBundleTargetPlatform
]
=
(
argResults
[
'target-platform'
]
as
List
<
String
>).
join
(
','
);
if
(
argResults
[
'release'
])
{
usage
[
CustomDimensions
.
commandBuildAppBundleBuildMode
]
=
'release'
;
}
else
if
(
argResults
[
'debug'
])
{
usage
[
CustomDimensions
.
commandBuildAppBundleBuildMode
]
=
'debug'
;
}
else
if
(
argResults
[
'profile'
])
{
usage
[
CustomDimensions
.
commandBuildAppBundleBuildMode
]
=
'profile'
;
}
else
{
// The build defaults to release.
usage
[
CustomDimensions
.
commandBuildAppBundleBuildMode
]
=
'release'
;
}
return
usage
;
}
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
final
AndroidBuildInfo
androidBuildInfo
=
AndroidBuildInfo
(
getBuildInfo
(),
final
AndroidBuildInfo
androidBuildInfo
=
AndroidBuildInfo
(
getBuildInfo
(),
targetArchs:
argResults
[
'target-platform'
].
map
<
AndroidArch
>(
getAndroidArchForName
)
targetArchs:
argResults
[
'target-platform'
].
map
<
AndroidArch
>(
getAndroidArchForName
)
);
);
await
buildAppBundle
(
await
androidBuilder
.
buildAab
(
project:
FlutterProject
.
current
(),
project:
FlutterProject
.
current
(),
target:
targetFile
,
target:
targetFile
,
androidBuildInfo:
androidBuildInfo
,
androidBuildInfo:
androidBuildInfo
,
...
...
packages/flutter_tools/lib/src/reporting/usage.dart
View file @
6266d5f3
...
@@ -48,6 +48,11 @@ enum CustomDimensions {
...
@@ -48,6 +48,11 @@ enum CustomDimensions {
commandBuildAarProjectType
,
// cd35
commandBuildAarProjectType
,
// cd35
buildEventCommand
,
// cd36
buildEventCommand
,
// cd36
buildEventSettings
,
// cd37
buildEventSettings
,
// cd37
commandBuildApkTargetPlatform
,
// cd38
commandBuildApkBuildMode
,
// cd39
commandBuildApkSplitPerAbi
,
// cd40
commandBuildAppBundleTargetPlatform
,
// cd41
commandBuildAppBundleBuildMode
,
// cd42
}
}
String
cdKey
(
CustomDimensions
cd
)
=>
'cd
${cd.index + 1}
'
;
String
cdKey
(
CustomDimensions
cd
)
=>
'cd
${cd.index + 1}
'
;
...
...
packages/flutter_tools/test/general.shard/commands/build_aar_test.dart
View file @
6266d5f3
...
@@ -3,12 +3,11 @@
...
@@ -3,12 +3,11 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:args/command_runner.dart'
;
import
'package:args/command_runner.dart'
;
import
'package:flutter_tools/src/android/a
a
r.dart'
;
import
'package:flutter_tools/src/android/a
ndroid_builde
r.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/build_aar.dart'
;
import
'package:flutter_tools/src/commands/build_aar.dart'
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'package:mockito/mockito.dart'
;
import
'../../src/common.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/context.dart'
;
...
@@ -18,16 +17,9 @@ void main() {
...
@@ -18,16 +17,9 @@ void main() {
group
(
'getUsage'
,
()
{
group
(
'getUsage'
,
()
{
Directory
tempDir
;
Directory
tempDir
;
AarBuilder
mockAarBuilder
;
setUp
(()
{
setUp
(()
{
tempDir
=
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_tools_packages_test.'
);
tempDir
=
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_tools_packages_test.'
);
mockAarBuilder
=
MockAarBuilder
();
when
(
mockAarBuilder
.
build
(
project:
anyNamed
(
'project'
),
androidBuildInfo:
anyNamed
(
'androidBuildInfo'
),
target:
anyNamed
(
'target'
),
outputDir:
anyNamed
(
'outputDir'
))).
thenAnswer
((
_
)
=>
Future
<
void
>.
value
());
});
});
tearDown
(()
{
tearDown
(()
{
...
@@ -54,7 +46,7 @@ void main() {
...
@@ -54,7 +46,7 @@ void main() {
containsPair
(
CustomDimensions
.
commandBuildAarProjectType
,
'module'
));
containsPair
(
CustomDimensions
.
commandBuildAarProjectType
,
'module'
));
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
A
arBuilder:
()
=>
mockAarBuilder
,
A
ndroidBuilder:
()
=>
FakeAndroidBuilder
()
,
},
timeout:
allowForCreateFlutterProject
);
},
timeout:
allowForCreateFlutterProject
);
testUsingContext
(
'indicate that project is a plugin'
,
()
async
{
testUsingContext
(
'indicate that project is a plugin'
,
()
async
{
...
@@ -66,7 +58,7 @@ void main() {
...
@@ -66,7 +58,7 @@ void main() {
containsPair
(
CustomDimensions
.
commandBuildAarProjectType
,
'plugin'
));
containsPair
(
CustomDimensions
.
commandBuildAarProjectType
,
'plugin'
));
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
A
arBuilder:
()
=>
mockAarBuilder
,
A
ndroidBuilder:
()
=>
FakeAndroidBuilder
()
,
},
timeout:
allowForCreateFlutterProject
);
},
timeout:
allowForCreateFlutterProject
);
testUsingContext
(
'indicate the target platform'
,
()
async
{
testUsingContext
(
'indicate the target platform'
,
()
async
{
...
@@ -79,9 +71,7 @@ void main() {
...
@@ -79,9 +71,7 @@ void main() {
containsPair
(
CustomDimensions
.
commandBuildAarTargetPlatform
,
'android-arm'
));
containsPair
(
CustomDimensions
.
commandBuildAarTargetPlatform
,
'android-arm'
));
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
A
arBuilder:
()
=>
mockAarBuilder
,
A
ndroidBuilder:
()
=>
FakeAndroidBuilder
()
,
},
timeout:
allowForCreateFlutterProject
);
},
timeout:
allowForCreateFlutterProject
);
});
});
}
}
class
MockAarBuilder
extends
Mock
implements
AarBuilder
{}
packages/flutter_tools/test/general.shard/commands/build_apk_test.dart
0 → 100644
View file @
6266d5f3
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:args/command_runner.dart'
;
import
'package:flutter_tools/src/android/android_builder.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/build_apk.dart'
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
void
main
(
)
{
Cache
.
disableLocking
();
group
(
'getUsage'
,
()
{
Directory
tempDir
;
setUp
(()
{
tempDir
=
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_tools_packages_test.'
);
});
tearDown
(()
{
tryToDelete
(
tempDir
);
});
Future
<
BuildApkCommand
>
runCommandIn
(
String
target
,
{
List
<
String
>
arguments
})
async
{
final
BuildApkCommand
command
=
BuildApkCommand
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
await
runner
.
run
(<
String
>[
'apk'
,
...?
arguments
,
fs
.
path
.
join
(
target
,
'lib'
,
'main.dart'
),
]);
return
command
;
}
testUsingContext
(
'indicate the default target platforms'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
arguments:
<
String
>[
'--no-pub'
,
'--template=app'
]);
final
BuildApkCommand
command
=
await
runCommandIn
(
projectPath
);
expect
(
await
command
.
usageValues
,
containsPair
(
CustomDimensions
.
commandBuildApkTargetPlatform
,
'android-arm,android-arm64'
));
},
overrides:
<
Type
,
Generator
>{
AndroidBuilder:
()
=>
FakeAndroidBuilder
(),
},
timeout:
allowForCreateFlutterProject
);
testUsingContext
(
'split per abi'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
arguments:
<
String
>[
'--no-pub'
,
'--template=app'
]);
final
BuildApkCommand
commandWithFlag
=
await
runCommandIn
(
projectPath
,
arguments:
<
String
>[
'--split-per-abi'
]);
expect
(
await
commandWithFlag
.
usageValues
,
containsPair
(
CustomDimensions
.
commandBuildApkSplitPerAbi
,
'true'
));
final
BuildApkCommand
commandWithoutFlag
=
await
runCommandIn
(
projectPath
);
expect
(
await
commandWithoutFlag
.
usageValues
,
containsPair
(
CustomDimensions
.
commandBuildApkSplitPerAbi
,
'false'
));
},
overrides:
<
Type
,
Generator
>{
AndroidBuilder:
()
=>
FakeAndroidBuilder
(),
},
timeout:
allowForCreateFlutterProject
);
testUsingContext
(
'build type'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
arguments:
<
String
>[
'--no-pub'
,
'--template=app'
]);
final
BuildApkCommand
commandDefault
=
await
runCommandIn
(
projectPath
);
expect
(
await
commandDefault
.
usageValues
,
containsPair
(
CustomDimensions
.
commandBuildApkBuildMode
,
'release'
));
final
BuildApkCommand
commandInRelease
=
await
runCommandIn
(
projectPath
,
arguments:
<
String
>[
'--release'
]);
expect
(
await
commandInRelease
.
usageValues
,
containsPair
(
CustomDimensions
.
commandBuildApkBuildMode
,
'release'
));
final
BuildApkCommand
commandInDebug
=
await
runCommandIn
(
projectPath
,
arguments:
<
String
>[
'--debug'
]);
expect
(
await
commandInDebug
.
usageValues
,
containsPair
(
CustomDimensions
.
commandBuildApkBuildMode
,
'debug'
));
final
BuildApkCommand
commandInProfile
=
await
runCommandIn
(
projectPath
,
arguments:
<
String
>[
'--profile'
]);
expect
(
await
commandInProfile
.
usageValues
,
containsPair
(
CustomDimensions
.
commandBuildApkBuildMode
,
'profile'
));
},
overrides:
<
Type
,
Generator
>{
AndroidBuilder:
()
=>
FakeAndroidBuilder
(),
},
timeout:
allowForCreateFlutterProject
);
});
}
packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart
0 → 100644
View file @
6266d5f3
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:args/command_runner.dart'
;
import
'package:flutter_tools/src/android/android_builder.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/build_appbundle.dart'
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
void
main
(
)
{
Cache
.
disableLocking
();
group
(
'getUsage'
,
()
{
Directory
tempDir
;
setUp
(()
{
tempDir
=
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_tools_packages_test.'
);
});
tearDown
(()
{
tryToDelete
(
tempDir
);
});
Future
<
BuildAppBundleCommand
>
runCommandIn
(
String
target
,
{
List
<
String
>
arguments
})
async
{
final
BuildAppBundleCommand
command
=
BuildAppBundleCommand
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
await
runner
.
run
(<
String
>[
'appbundle'
,
...?
arguments
,
fs
.
path
.
join
(
target
,
'lib'
,
'main.dart'
),
]);
return
command
;
}
testUsingContext
(
'indicate the default target platforms'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
arguments:
<
String
>[
'--no-pub'
,
'--template=app'
]);
final
BuildAppBundleCommand
command
=
await
runCommandIn
(
projectPath
);
expect
(
await
command
.
usageValues
,
containsPair
(
CustomDimensions
.
commandBuildAppBundleTargetPlatform
,
'android-arm,android-arm64'
));
},
overrides:
<
Type
,
Generator
>{
AndroidBuilder:
()
=>
FakeAndroidBuilder
(),
},
timeout:
allowForCreateFlutterProject
);
testUsingContext
(
'build type'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
arguments:
<
String
>[
'--no-pub'
,
'--template=app'
]);
final
BuildAppBundleCommand
commandDefault
=
await
runCommandIn
(
projectPath
);
expect
(
await
commandDefault
.
usageValues
,
containsPair
(
CustomDimensions
.
commandBuildAppBundleBuildMode
,
'release'
));
final
BuildAppBundleCommand
commandInRelease
=
await
runCommandIn
(
projectPath
,
arguments:
<
String
>[
'--release'
]);
expect
(
await
commandInRelease
.
usageValues
,
containsPair
(
CustomDimensions
.
commandBuildAppBundleBuildMode
,
'release'
));
final
BuildAppBundleCommand
commandInDebug
=
await
runCommandIn
(
projectPath
,
arguments:
<
String
>[
'--debug'
]);
expect
(
await
commandInDebug
.
usageValues
,
containsPair
(
CustomDimensions
.
commandBuildAppBundleBuildMode
,
'debug'
));
final
BuildAppBundleCommand
commandInProfile
=
await
runCommandIn
(
projectPath
,
arguments:
<
String
>[
'--profile'
]);
expect
(
await
commandInProfile
.
usageValues
,
containsPair
(
CustomDimensions
.
commandBuildAppBundleBuildMode
,
'profile'
));
},
overrides:
<
Type
,
Generator
>{
AndroidBuilder:
()
=>
FakeAndroidBuilder
(),
},
timeout:
allowForCreateFlutterProject
);
});
}
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