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
b678d0ad
Unverified
Commit
b678d0ad
authored
Feb 20, 2021
by
Jonah Williams
Committed by
GitHub
Feb 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] remove globals and mocks from android gradle builder and test (#76416)
parent
e204b896
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
123 additions
and
319 deletions
+123
-319
gradle.dart
packages/flutter_tools/lib/src/android/gradle.dart
+48
-56
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+2
-0
build_aar_test.dart
...r_tools/test/commands.shard/permeable/build_aar_test.dart
+0
-21
build_apk_test.dart
...r_tools/test/commands.shard/permeable/build_apk_test.dart
+0
-21
build_appbundle_test.dart
...s/test/commands.shard/permeable/build_appbundle_test.dart
+0
-21
android_gradle_builder_test.dart
...st/general.shard/android/android_gradle_builder_test.dart
+71
-200
gradle_test.dart
...flutter_tools/test/general.shard/android/gradle_test.dart
+2
-0
No files found.
packages/flutter_tools/lib/src/android/gradle.dart
View file @
b678d0ad
...
@@ -15,6 +15,7 @@ import '../base/common.dart';
...
@@ -15,6 +15,7 @@ import '../base/common.dart';
import
'../base/file_system.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/io.dart'
;
import
'../base/logger.dart'
;
import
'../base/logger.dart'
;
import
'../base/platform.dart'
;
import
'../base/process.dart'
;
import
'../base/process.dart'
;
import
'../base/terminal.dart'
;
import
'../base/terminal.dart'
;
import
'../base/utils.dart'
;
import
'../base/utils.dart'
;
...
@@ -22,7 +23,6 @@ import '../build_info.dart';
...
@@ -22,7 +23,6 @@ import '../build_info.dart';
import
'../cache.dart'
;
import
'../cache.dart'
;
import
'../convert.dart'
;
import
'../convert.dart'
;
import
'../flutter_manifest.dart'
;
import
'../flutter_manifest.dart'
;
import
'../globals.dart'
as
globals
hide
logger
,
printStatus
,
printTrace
,
printError
,
processManager
,
processUtils
,
fs
,
artifacts
,
flutterUsage
;
import
'../project.dart'
;
import
'../project.dart'
;
import
'../reporting/reporting.dart'
;
import
'../reporting/reporting.dart'
;
import
'android_builder.dart'
;
import
'android_builder.dart'
;
...
@@ -165,10 +165,14 @@ class AndroidGradleBuilder implements AndroidBuilder {
...
@@ -165,10 +165,14 @@ class AndroidGradleBuilder implements AndroidBuilder {
@required
FileSystem
fileSystem
,
@required
FileSystem
fileSystem
,
@required
Artifacts
artifacts
,
@required
Artifacts
artifacts
,
@required
Usage
usage
,
@required
Usage
usage
,
@required
GradleUtils
gradleUtils
,
@required
Platform
platform
,
})
:
_logger
=
logger
,
})
:
_logger
=
logger
,
_fileSystem
=
fileSystem
,
_fileSystem
=
fileSystem
,
_artifacts
=
artifacts
,
_artifacts
=
artifacts
,
_usage
=
usage
,
_usage
=
usage
,
_gradleUtils
=
gradleUtils
,
_fileSystemUtils
=
FileSystemUtils
(
fileSystem:
fileSystem
,
platform:
platform
),
_processUtils
=
ProcessUtils
(
logger:
logger
,
processManager:
processManager
);
_processUtils
=
ProcessUtils
(
logger:
logger
,
processManager:
processManager
);
final
Logger
_logger
;
final
Logger
_logger
;
...
@@ -176,6 +180,8 @@ class AndroidGradleBuilder implements AndroidBuilder {
...
@@ -176,6 +180,8 @@ class AndroidGradleBuilder implements AndroidBuilder {
final
FileSystem
_fileSystem
;
final
FileSystem
_fileSystem
;
final
Artifacts
_artifacts
;
final
Artifacts
_artifacts
;
final
Usage
_usage
;
final
Usage
_usage
;
final
GradleUtils
_gradleUtils
;
final
FileSystemUtils
_fileSystemUtils
;
/// 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
...
@@ -186,36 +192,32 @@ class AndroidGradleBuilder implements AndroidBuilder {
...
@@ -186,36 +192,32 @@ class AndroidGradleBuilder implements AndroidBuilder {
@required
String
outputDirectoryPath
,
@required
String
outputDirectoryPath
,
@required
String
buildNumber
,
@required
String
buildNumber
,
})
async
{
})
async
{
try
{
Directory
outputDirectory
=
Directory
outputDirectory
=
_fileSystem
.
directory
(
outputDirectoryPath
??
project
.
android
.
buildDirectory
);
_fileSystem
.
directory
(
outputDirectoryPath
??
project
.
android
.
buildDirectory
);
if
(
project
.
isModule
)
{
if
(
project
.
isModule
)
{
// Module projects artifacts are located in `build/host`.
// Module projects artifacts are located in `build/host`.
outputDirectory
=
outputDirectory
.
childDirectory
(
'host'
);
outputDirectory
=
outputDirectory
.
childDirectory
(
'host'
);
}
}
for
(
final
AndroidBuildInfo
androidBuildInfo
in
androidBuildInfo
)
{
for
(
final
AndroidBuildInfo
androidBuildInfo
in
androidBuildInfo
)
{
await
buildGradleAar
(
await
buildGradleAar
(
project:
project
,
project:
project
,
androidBuildInfo:
androidBuildInfo
,
androidBuildInfo:
androidBuildInfo
,
target:
target
,
target:
target
,
outputDirectory:
outputDirectory
,
outputDirectory:
outputDirectory
,
buildNumber:
buildNumber
,
);
}
printHowToConsumeAar
(
buildModes:
androidBuildInfo
.
map
<
String
>((
AndroidBuildInfo
androidBuildInfo
)
{
return
androidBuildInfo
.
buildInfo
.
modeName
;
}).
toSet
(),
androidPackage:
project
.
manifest
.
androidPackage
,
repoDirectory:
getRepoDirectory
(
outputDirectory
),
buildNumber:
buildNumber
,
buildNumber:
buildNumber
,
logger:
_logger
,
fileSystem:
_fileSystem
,
);
);
}
finally
{
globals
.
androidSdk
?.
reinitialize
();
}
}
printHowToConsumeAar
(
buildModes:
androidBuildInfo
.
map
<
String
>((
AndroidBuildInfo
androidBuildInfo
)
{
return
androidBuildInfo
.
buildInfo
.
modeName
;
}).
toSet
(),
androidPackage:
project
.
manifest
.
androidPackage
,
repoDirectory:
getRepoDirectory
(
outputDirectory
),
buildNumber:
buildNumber
,
logger:
_logger
,
fileSystem:
_fileSystem
,
);
}
}
/// Builds the APK.
/// Builds the APK.
...
@@ -225,17 +227,13 @@ class AndroidGradleBuilder implements AndroidBuilder {
...
@@ -225,17 +227,13 @@ class AndroidGradleBuilder implements AndroidBuilder {
@required
AndroidBuildInfo
androidBuildInfo
,
@required
AndroidBuildInfo
androidBuildInfo
,
@required
String
target
,
@required
String
target
,
})
async
{
})
async
{
try
{
await
buildGradleApp
(
await
buildGradleApp
(
project:
project
,
project:
project
,
androidBuildInfo:
androidBuildInfo
,
androidBuildInfo:
androidBuildInfo
,
target:
target
,
target:
target
,
isBuildingBundle:
false
,
isBuildingBundle:
false
,
localGradleErrors:
gradleErrors
,
localGradleErrors:
gradleErrors
,
);
);
}
finally
{
globals
.
androidSdk
?.
reinitialize
();
}
}
}
/// Builds the App Bundle.
/// Builds the App Bundle.
...
@@ -245,17 +243,13 @@ class AndroidGradleBuilder implements AndroidBuilder {
...
@@ -245,17 +243,13 @@ class AndroidGradleBuilder implements AndroidBuilder {
@required
AndroidBuildInfo
androidBuildInfo
,
@required
AndroidBuildInfo
androidBuildInfo
,
@required
String
target
,
@required
String
target
,
})
async
{
})
async
{
try
{
await
buildGradleApp
(
await
buildGradleApp
(
project:
project
,
project:
project
,
androidBuildInfo:
androidBuildInfo
,
androidBuildInfo:
androidBuildInfo
,
target:
target
,
target:
target
,
isBuildingBundle:
true
,
isBuildingBundle:
true
,
localGradleErrors:
gradleErrors
,
localGradleErrors:
gradleErrors
,
);
);
}
finally
{
globals
.
androidSdk
?.
reinitialize
();
}
}
}
/// Builds an app.
/// Builds an app.
...
@@ -283,7 +277,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
...
@@ -283,7 +277,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
assert
(
target
!=
null
);
assert
(
target
!=
null
);
assert
(
isBuildingBundle
!=
null
);
assert
(
isBuildingBundle
!=
null
);
assert
(
localGradleErrors
!=
null
);
assert
(
localGradleErrors
!=
null
);
assert
(
globals
.
androidSdk
!=
null
);
if
(!
project
.
android
.
isSupportedVersion
)
{
if
(!
project
.
android
.
isSupportedVersion
)
{
_exitWithUnsupportedProjectMessage
(
_usage
);
_exitWithUnsupportedProjectMessage
(
_usage
);
...
@@ -327,7 +320,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
...
@@ -327,7 +320,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
);
);
final
List
<
String
>
command
=
<
String
>[
final
List
<
String
>
command
=
<
String
>[
globals
.
gradleUtils
.
getExecutable
(
project
),
_
gradleUtils
.
getExecutable
(
project
),
];
];
if
(
_logger
.
isVerbose
)
{
if
(
_logger
.
isVerbose
)
{
command
.
add
(
'-Pverbose=true'
);
command
.
add
(
'-Pverbose=true'
);
...
@@ -565,9 +558,9 @@ class AndroidGradleBuilder implements AndroidBuilder {
...
@@ -565,9 +558,9 @@ class AndroidGradleBuilder implements AndroidBuilder {
precompilerTrace:
precompilerTrace
,
precompilerTrace:
precompilerTrace
,
kind:
kind
,
kind:
kind
,
);
);
final
File
outputFile
=
globals
.
fs
Utils
.
getUniqueFile
(
final
File
outputFile
=
_fileSystem
Utils
.
getUniqueFile
(
_fileSystem
_fileSystem
.
directory
(
globals
.
fs
Utils
.
homeDirPath
)
.
directory
(
_fileSystem
Utils
.
homeDirPath
)
.
childDirectory
(
'.flutter-devtools'
),
'
$kind
-code-size-analysis'
,
'json'
,
.
childDirectory
(
'.flutter-devtools'
),
'
$kind
-code-size-analysis'
,
'json'
,
)
)
..
writeAsStringSync
(
jsonEncode
(
output
));
..
writeAsStringSync
(
jsonEncode
(
output
));
...
@@ -605,7 +598,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
...
@@ -605,7 +598,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
assert
(
target
!=
null
);
assert
(
target
!=
null
);
assert
(
androidBuildInfo
!=
null
);
assert
(
androidBuildInfo
!=
null
);
assert
(
outputDirectory
!=
null
);
assert
(
outputDirectory
!=
null
);
assert
(
globals
.
androidSdk
!=
null
);
final
FlutterManifest
manifest
=
project
.
manifest
;
final
FlutterManifest
manifest
=
project
.
manifest
;
if
(!
manifest
.
isModule
&&
!
manifest
.
isPlugin
)
{
if
(!
manifest
.
isModule
&&
!
manifest
.
isPlugin
)
{
...
@@ -628,7 +620,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
...
@@ -628,7 +620,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
'aar_init_script.gradle'
,
'aar_init_script.gradle'
,
);
);
final
List
<
String
>
command
=
<
String
>[
final
List
<
String
>
command
=
<
String
>[
globals
.
gradleUtils
.
getExecutable
(
project
),
_
gradleUtils
.
getExecutable
(
project
),
'-I=
$initScript
'
,
'-I=
$initScript
'
,
'-Pflutter-root=
$flutterRoot
'
,
'-Pflutter-root=
$flutterRoot
'
,
'-Poutput-dir=
${outputDirectory.path}
'
,
'-Poutput-dir=
${outputDirectory.path}
'
,
...
...
packages/flutter_tools/lib/src/context_runner.dart
View file @
b678d0ad
...
@@ -85,6 +85,8 @@ Future<T> runInContext<T>(
...
@@ -85,6 +85,8 @@ Future<T> runInContext<T>(
fileSystem:
globals
.
fs
,
fileSystem:
globals
.
fs
,
artifacts:
globals
.
artifacts
,
artifacts:
globals
.
artifacts
,
usage:
globals
.
flutterUsage
,
usage:
globals
.
flutterUsage
,
gradleUtils:
globals
.
gradleUtils
,
platform:
globals
.
platform
,
),
),
AndroidLicenseValidator:
()
=>
AndroidLicenseValidator
(
AndroidLicenseValidator:
()
=>
AndroidLicenseValidator
(
operatingSystemUtils:
globals
.
os
,
operatingSystemUtils:
globals
.
os
,
...
...
packages/flutter_tools/test/commands.shard/permeable/build_aar_test.dart
View file @
b678d0ad
...
@@ -235,27 +235,6 @@ void main() {
...
@@ -235,27 +235,6 @@ void main() {
});
});
group
(
'AndroidSdk'
,
()
{
group
(
'AndroidSdk'
,
()
{
testUsingContext
(
'validateSdkWellFormed() not called, sdk reinitialized'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
arguments:
<
String
>[
'--no-pub'
,
'--template=module'
]);
await
expectLater
(
runBuildAarCommand
(
projectPath
,
arguments:
<
String
>[
'--no-pub'
],
),
throwsToolExit
(),
);
verifyNever
(
mockAndroidSdk
.
validateSdkWellFormed
());
verify
(
mockAndroidSdk
.
reinitialize
()).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
FlutterProjectFactory:
()
=>
FakeFlutterProjectFactory
(
tempDir
),
ProcessManager:
()
=>
mockProcessManager
,
});
testUsingContext
(
'throws throwsToolExit if AndroidSdk is null'
,
()
async
{
testUsingContext
(
'throws throwsToolExit if AndroidSdk is null'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
final
String
projectPath
=
await
createProject
(
tempDir
,
arguments:
<
String
>[
'--no-pub'
,
'--template=module'
]);
arguments:
<
String
>[
'--no-pub'
,
'--template=module'
]);
...
...
packages/flutter_tools/test/commands.shard/permeable/build_apk_test.dart
View file @
b678d0ad
...
@@ -182,27 +182,6 @@ void main() {
...
@@ -182,27 +182,6 @@ void main() {
});
});
group
(
'AndroidSdk'
,
()
{
group
(
'AndroidSdk'
,
()
{
testUsingContext
(
'validateSdkWellFormed() not called, sdk reinitialized'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
arguments:
<
String
>[
'--no-pub'
,
'--template=app'
]);
await
expectLater
(
runBuildApkCommand
(
projectPath
,
arguments:
<
String
>[
'--no-pub'
],
),
throwsToolExit
(
message:
'Gradle task assembleRelease failed with exit code 1'
),
);
verifyNever
(
mockAndroidSdk
.
validateSdkWellFormed
());
verify
(
mockAndroidSdk
.
reinitialize
()).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
FlutterProjectFactory:
()
=>
FakeFlutterProjectFactory
(
tempDir
),
ProcessManager:
()
=>
mockProcessManager
,
});
testUsingContext
(
'throws throwsToolExit if AndroidSdk is null'
,
()
async
{
testUsingContext
(
'throws throwsToolExit if AndroidSdk is null'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
final
String
projectPath
=
await
createProject
(
tempDir
,
arguments:
<
String
>[
'--no-pub'
,
'--template=app'
]);
arguments:
<
String
>[
'--no-pub'
,
'--template=app'
]);
...
...
packages/flutter_tools/test/commands.shard/permeable/build_appbundle_test.dart
View file @
b678d0ad
...
@@ -162,27 +162,6 @@ void main() {
...
@@ -162,27 +162,6 @@ void main() {
});
});
group
(
'AndroidSdk'
,
()
{
group
(
'AndroidSdk'
,
()
{
testUsingContext
(
'validateSdkWellFormed() not called, sdk reinitialized'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
arguments:
<
String
>[
'--no-pub'
,
'--template=app'
]);
await
expectLater
(
runBuildAppBundleCommand
(
projectPath
,
arguments:
<
String
>[
'--no-pub'
],
),
throwsToolExit
(
message:
'Gradle task bundleRelease failed with exit code 1'
),
);
verifyNever
(
mockAndroidSdk
.
validateSdkWellFormed
());
verify
(
mockAndroidSdk
.
reinitialize
()).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
FlutterProjectFactory:
()
=>
FakeFlutterProjectFactory
(
tempDir
),
ProcessManager:
()
=>
mockProcessManager
,
});
testUsingContext
(
'throws throwsToolExit if AndroidSdk is null'
,
()
async
{
testUsingContext
(
'throws throwsToolExit if AndroidSdk is null'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
final
String
projectPath
=
await
createProject
(
tempDir
,
arguments:
<
String
>[
'--no-pub'
,
'--template=app'
]);
arguments:
<
String
>[
'--no-pub'
,
'--template=app'
]);
...
...
packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart
View file @
b678d0ad
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/android/gradle_test.dart
View file @
b678d0ad
...
@@ -646,6 +646,8 @@ flutter:
...
@@ -646,6 +646,8 @@ flutter:
fileSystem:
fs
,
fileSystem:
fs
,
artifacts:
Artifacts
.
test
(),
artifacts:
Artifacts
.
test
(),
usage:
TestUsage
(),
usage:
TestUsage
(),
gradleUtils:
FakeGradleUtils
(),
platform:
FakePlatform
(),
);
);
});
});
...
...
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