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
bfcb43d2
Unverified
Commit
bfcb43d2
authored
Feb 18, 2021
by
Jonah Williams
Committed by
GitHub
Feb 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] remove local engine from globals in gradle (#76277)
parent
7233d963
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
165 additions
and
149 deletions
+165
-149
gradle.dart
packages/flutter_tools/lib/src/android/gradle.dart
+8
-15
artifacts.dart
packages/flutter_tools/lib/src/artifacts.dart
+35
-4
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+1
-0
android_gradle_builder_test.dart
...st/general.shard/android/android_gradle_builder_test.dart
+115
-129
gradle_test.dart
...flutter_tools/test/general.shard/android/gradle_test.dart
+6
-1
No files found.
packages/flutter_tools/lib/src/android/gradle.dart
View file @
bfcb43d2
...
...
@@ -22,7 +22,7 @@ import '../build_info.dart';
import
'../cache.dart'
;
import
'../convert.dart'
;
import
'../flutter_manifest.dart'
;
import
'../globals.dart'
as
globals
hide
logger
,
printStatus
,
printTrace
,
printError
,
processManager
,
processUtils
,
fs
;
import
'../globals.dart'
as
globals
hide
logger
,
printStatus
,
printTrace
,
printError
,
processManager
,
processUtils
,
fs
,
artifacts
;
import
'../project.dart'
;
import
'../reporting/reporting.dart'
;
import
'android_builder.dart'
;
...
...
@@ -216,13 +216,16 @@ class AndroidGradleBuilder implements AndroidBuilder {
@required
Logger
logger
,
@required
ProcessManager
processManager
,
@required
FileSystem
fileSystem
,
@required
Artifacts
artifacts
,
})
:
_logger
=
logger
,
_fileSystem
=
fileSystem
,
_artifacts
=
artifacts
,
_processUtils
=
ProcessUtils
(
logger:
logger
,
processManager:
processManager
);
final
Logger
_logger
;
final
ProcessUtils
_processUtils
;
final
FileSystem
_fileSystem
;
final
Artifacts
_artifacts
;
/// Builds the AAR and POM files for the current Flutter module or plugin.
@override
...
...
@@ -387,8 +390,8 @@ class AndroidGradleBuilder implements AndroidBuilder {
if
(!
buildInfo
.
androidGradleDaemon
)
{
command
.
add
(
'--no-daemon'
);
}
if
(
globals
.
artifacts
is
LocalEngineArtifacts
)
{
final
LocalEngineArtifacts
localEngineArtifacts
=
globals
.
artifacts
as
LocalEngineArtifacts
;
if
(
_
artifacts
is
LocalEngineArtifacts
)
{
final
LocalEngineArtifacts
localEngineArtifacts
=
_
artifacts
as
LocalEngineArtifacts
;
final
Directory
localEngineRepo
=
_getLocalEngineRepo
(
engineOutPath:
localEngineArtifacts
.
engineOutPath
,
androidBuildInfo:
androidBuildInfo
,
...
...
@@ -704,8 +707,8 @@ class AndroidGradleBuilder implements AndroidBuilder {
);
}
if
(
globals
.
artifacts
is
LocalEngineArtifacts
)
{
final
LocalEngineArtifacts
localEngineArtifacts
=
globals
.
artifacts
as
LocalEngineArtifacts
;
if
(
_
artifacts
is
LocalEngineArtifacts
)
{
final
LocalEngineArtifacts
localEngineArtifacts
=
_
artifacts
as
LocalEngineArtifacts
;
final
Directory
localEngineRepo
=
_getLocalEngineRepo
(
engineOutPath:
localEngineArtifacts
.
engineOutPath
,
androidBuildInfo:
androidBuildInfo
,
...
...
@@ -1137,16 +1140,6 @@ Directory _getLocalEngineRepo({
final
String
abi
=
_getAbiByLocalEnginePath
(
engineOutPath
);
final
Directory
localEngineRepo
=
fileSystem
.
systemTempDirectory
.
createTempSync
(
'flutter_tool_local_engine_repo.'
);
// Remove the local engine repo before the tool exits.
shutdownHooks
.
addShutdownHook
(()
{
if
(
localEngineRepo
.
existsSync
())
{
localEngineRepo
.
deleteSync
(
recursive:
true
);
}
},
ShutdownStage
.
CLEANUP
,
);
final
String
buildMode
=
androidBuildInfo
.
buildInfo
.
modeName
;
final
String
artifactVersion
=
_getLocalArtifactVersion
(
fileSystem
.
path
.
join
(
...
...
packages/flutter_tools/lib/src/artifacts.dart
View file @
bfcb43d2
...
...
@@ -209,8 +209,15 @@ class EngineBuildPaths {
abstract
class
Artifacts
{
/// A test-specific implementation of artifacts that returns stable paths for
/// all artifacts.
///
/// Creates a [LocalEngineArtifacts] if `localEngine` is non-null
@visibleForTesting
factory
Artifacts
.
test
()
=
_TestArtifacts
;
factory
Artifacts
.
test
({
String
localEngine
})
{
if
(
localEngine
!=
null
)
{
return
_TestLocalEngine
(
localEngine
);
}
return
_TestArtifacts
();
}
static
LocalEngineArtifacts
getLocalEngine
(
EngineBuildPaths
engineBuildPaths
)
{
return
LocalEngineArtifacts
(
...
...
@@ -569,9 +576,21 @@ String _getIosEngineArtifactPath(String engineDirectory,
.
path
;
}
abstract
class
LocalEngineArtifacts
implements
Artifacts
{
factory
LocalEngineArtifacts
(
String
engineOutPath
,
String
hostEngineOutPath
,
{
@required
FileSystem
fileSystem
,
@required
Cache
cache
,
@required
ProcessManager
processManager
,
@required
Platform
platform
,
@required
OperatingSystemUtils
operatingSystemUtils
,
})
=
CachedLocalEngineArtifacts
;
String
get
engineOutPath
;
}
/// Manages the artifacts of a locally built engine.
class
LocalEngineArtifacts
implements
Artifacts
{
LocalEngineArtifacts
(
class
CachedLocalEngineArtifacts
implements
LocalEngine
Artifacts
{
Cached
LocalEngineArtifacts
(
this
.
engineOutPath
,
this
.
_hostEngineOutPath
,
{
@required
FileSystem
fileSystem
,
...
...
@@ -585,7 +604,9 @@ class LocalEngineArtifacts implements Artifacts {
_platform
=
platform
,
_operatingSystemUtils
=
operatingSystemUtils
;
final
String
engineOutPath
;
// TODO(goderbauer): This should be private.
@override
final
String
engineOutPath
;
final
String
_hostEngineOutPath
;
final
FileSystem
_fileSystem
;
final
Cache
_cache
;
...
...
@@ -847,3 +868,13 @@ class _TestArtifacts implements Artifacts {
@override
bool
get
isLocalEngine
=>
false
;
}
class
_TestLocalEngine
extends
_TestArtifacts
implements
LocalEngineArtifacts
{
_TestLocalEngine
(
this
.
engineOutPath
);
@override
bool
get
isLocalEngine
=>
true
;
@override
final
String
engineOutPath
;
}
packages/flutter_tools/lib/src/context_runner.dart
View file @
bfcb43d2
...
...
@@ -83,6 +83,7 @@ Future<T> runInContext<T>(
logger:
globals
.
logger
,
processManager:
globals
.
processManager
,
fileSystem:
globals
.
fs
,
artifacts:
globals
.
artifacts
,
),
AndroidLicenseValidator:
()
=>
AndroidLicenseValidator
(
operatingSystemUtils:
globals
.
os
,
...
...
packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart
View file @
bfcb43d2
...
...
@@ -33,11 +33,9 @@ void main() {
TestUsage
testUsage
;
MockAndroidSdk
mockAndroidSdk
;
MockAndroidStudio
mockAndroidStudio
;
MockLocalEngineArtifacts
mockArtifacts
;
FakePlatform
android
;
FileSystem
fileSystem
;
Cache
cache
;
AndroidGradleBuilder
builder
;
FakeProcessManager
processManager
;
setUp
(()
{
...
...
@@ -47,14 +45,7 @@ void main() {
fileSystem
=
MemoryFileSystem
.
test
();
mockAndroidSdk
=
MockAndroidSdk
();
mockAndroidStudio
=
MockAndroidStudio
();
mockArtifacts
=
MockLocalEngineArtifacts
();
android
=
fakePlatform
(
'android'
);
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
);
when
(
mockAndroidSdk
.
directory
).
thenReturn
(
fileSystem
.
directory
(
'irrelevant'
));
final
Directory
rootDirectory
=
fileSystem
.
currentDirectory
;
...
...
@@ -85,6 +76,12 @@ void main() {
});
testUsingContext
(
'Can immediately tool exit on recognized exit code/stderr'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/android/gradlew'
,
...
...
@@ -170,6 +167,12 @@ void main() {
});
testUsingContext
(
'Can retry build on recognized exit code/stderr'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/android/gradlew'
,
...
...
@@ -270,6 +273,12 @@ void main() {
});
testUsingContext
(
'Converts recognized ProcessExceptions into tools exits'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/android/gradlew'
,
...
...
@@ -355,6 +364,12 @@ void main() {
});
testUsingContext
(
'rethrows unrecognized ProcessException'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(),
);
processManager
.
addCommand
(
FakeCommand
(
command:
const
<
String
>[
'/android/gradlew'
,
...
...
@@ -412,6 +427,12 @@ void main() {
});
testUsingContext
(
'logs success event after a successful retry'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/android/gradlew'
,
...
...
@@ -508,6 +529,12 @@ void main() {
});
testUsingContext
(
'performs code size analysis and sends analytics'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/android/gradlew'
,
...
...
@@ -599,6 +626,12 @@ void main() {
});
testUsingContext
(
'Can retry gradle build with plugins built as AARs'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/android/gradlew'
,
...
...
@@ -708,6 +741,12 @@ void main() {
});
testUsingContext
(
'indicates that an APK has been built successfully'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/android/gradlew'
,
...
...
@@ -769,6 +808,12 @@ void main() {
});
testUsingContext
(
"doesn't indicate how to consume an AAR when printHowToConsumeAar is false"
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/.android/gradlew'
,
...
...
@@ -797,13 +842,10 @@ void main() {
);
fileSystem
.
file
(
'.android/gradlew'
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
'.android/gradle.properties'
)
.
writeAsStringSync
(
'irrelevant'
);
fileSystem
.
file
(
'.android/build.gradle'
)
.
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'build/outputs/repo'
).
createSync
(
recursive:
true
);
await
builder
.
buildGradleAar
(
...
...
@@ -833,6 +875,12 @@ void main() {
});
testUsingContext
(
'gradle exit code and stderr is forwarded to tool exit'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/.android/gradlew'
,
...
...
@@ -862,13 +910,10 @@ void main() {
);
fileSystem
.
file
(
'.android/gradlew'
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
'.android/gradle.properties'
)
.
writeAsStringSync
(
'irrelevant'
);
fileSystem
.
file
(
'.android/build.gradle'
)
.
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'build/outputs/repo'
).
createSync
(
recursive:
true
);
await
expectLater
(()
async
=>
...
...
@@ -890,6 +935,12 @@ void main() {
});
testUsingContext
(
'build apk uses selected local engine with arm32 ABI'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(
localEngine:
'out/android_arm'
),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/android/gradlew'
,
...
...
@@ -907,14 +958,6 @@ void main() {
exitCode:
0
,
));
when
(
mockArtifacts
.
getArtifactPath
(
Artifact
.
flutterFramework
,
platform:
TargetPlatform
.
android_arm
,
mode:
anyNamed
(
'mode'
),
environmentType:
anyNamed
(
'environmentType'
),
)).
thenReturn
(
'engine'
);
when
(
mockArtifacts
.
engineOutPath
).
thenReturn
(
fileSystem
.
path
.
join
(
'out'
,
'android_arm'
));
fileSystem
.
file
(
'out/android_arm/flutter_embedding_release.pom'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
...
...
@@ -933,14 +976,11 @@ void main() {
fileSystem
.
file
(
'out/android_arm/flutter_embedding_release.maven-metadata.xml'
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
'android/gradlew'
).
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'android'
)
.
childFile
(
'gradle.properties'
)
.
createSync
(
recursive:
true
);
fileSystem
.
file
(
'android/build.gradle'
)
.
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'android'
)
.
childDirectory
(
'app'
)
.
childFile
(
'build.gradle'
)
...
...
@@ -962,17 +1002,10 @@ void main() {
localGradleErrors:
const
<
GradleHandledError
>[],
);
},
throwsToolExit
());
// expect(actualGradlewCall, contains('/android/gradlew'));
// expect(actualGradlewCall, contains('-Plocal-engine-out=out/android_arm'));
// expect(actualGradlewCall, contains('-Plocal-engine-repo=/.tmp_rand0/flutter_tool_local_engine_repo.rand0'));
// expect(actualGradlewCall, contains('-Plocal-engine-build-mode=release'));
expect
(
processManager
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
AndroidStudio:
()
=>
mockAndroidStudio
,
Artifacts:
()
=>
mockArtifacts
,
Cache:
()
=>
cache
,
Platform:
()
=>
android
,
FileSystem:
()
=>
fileSystem
,
...
...
@@ -980,6 +1013,12 @@ void main() {
});
testUsingContext
(
'build apk uses selected local engine with arm64 ABI'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(
localEngine:
'out/android_arm64'
),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/android/gradlew'
,
...
...
@@ -997,14 +1036,6 @@ void main() {
exitCode:
0
,
));
when
(
mockArtifacts
.
getArtifactPath
(
Artifact
.
flutterFramework
,
platform:
anyNamed
(
'platform'
),
mode:
anyNamed
(
'mode'
),
environmentType:
anyNamed
(
'environmentType'
),
)).
thenReturn
(
'engine'
);
when
(
mockArtifacts
.
engineOutPath
).
thenReturn
(
fileSystem
.
path
.
join
(
'out'
,
'android_arm64'
));
fileSystem
.
file
(
'out/android_arm64/flutter_embedding_release.pom'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
...
...
@@ -1023,14 +1054,11 @@ void main() {
fileSystem
.
file
(
'out/android_arm64/flutter_embedding_release.maven-metadata.xml'
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
'android/gradlew'
).
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'android'
)
.
childFile
(
'gradle.properties'
)
.
createSync
(
recursive:
true
);
fileSystem
.
file
(
'android/build.gradle'
)
.
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'android'
)
.
childDirectory
(
'app'
)
.
childFile
(
'build.gradle'
)
...
...
@@ -1056,7 +1084,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
AndroidStudio:
()
=>
mockAndroidStudio
,
Artifacts:
()
=>
mockArtifacts
,
Cache:
()
=>
cache
,
Platform:
()
=>
android
,
FileSystem:
()
=>
fileSystem
,
...
...
@@ -1064,6 +1091,12 @@ void main() {
});
testUsingContext
(
'build apk uses selected local engine with x86 ABI'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(
localEngine:
'out/android_x86'
),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/android/gradlew'
,
...
...
@@ -1081,14 +1114,6 @@ void main() {
exitCode:
0
,
));
when
(
mockArtifacts
.
getArtifactPath
(
Artifact
.
flutterFramework
,
platform:
anyNamed
(
'platform'
),
mode:
anyNamed
(
'mode'
),
environmentType:
anyNamed
(
'environmentType'
),
)).
thenReturn
(
'engine'
);
when
(
mockArtifacts
.
engineOutPath
).
thenReturn
(
fileSystem
.
path
.
join
(
'out'
,
'android_x86'
));
fileSystem
.
file
(
'out/android_x86/flutter_embedding_release.pom'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
...
...
@@ -1107,14 +1132,11 @@ void main() {
fileSystem
.
file
(
'out/android_x86/flutter_embedding_release.maven-metadata.xml'
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
'android/gradlew'
).
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'android'
)
.
childFile
(
'gradle.properties'
)
.
createSync
(
recursive:
true
);
fileSystem
.
file
(
'android/build.gradle'
)
.
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'android'
)
.
childDirectory
(
'app'
)
.
childFile
(
'build.gradle'
)
...
...
@@ -1140,7 +1162,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
AndroidStudio:
()
=>
mockAndroidStudio
,
Artifacts:
()
=>
mockArtifacts
,
Cache:
()
=>
cache
,
Platform:
()
=>
android
,
FileSystem:
()
=>
fileSystem
,
...
...
@@ -1148,6 +1169,12 @@ void main() {
});
testUsingContext
(
'build apk uses selected local engine with x64 ABI'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(
localEngine:
'out/android_x64'
),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/android/gradlew'
,
...
...
@@ -1165,14 +1192,6 @@ void main() {
exitCode:
1
,
));
when
(
mockArtifacts
.
getArtifactPath
(
Artifact
.
flutterFramework
,
platform:
anyNamed
(
'platform'
),
mode:
anyNamed
(
'mode'
),
environmentType:
anyNamed
(
'environmentType'
),
)).
thenReturn
(
'engine'
);
when
(
mockArtifacts
.
engineOutPath
).
thenReturn
(
fileSystem
.
path
.
join
(
'out'
,
'android_x64'
));
fileSystem
.
file
(
'out/android_x64/flutter_embedding_release.pom'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
...
...
@@ -1191,14 +1210,11 @@ void main() {
fileSystem
.
file
(
'out/android_x64/flutter_embedding_release.maven-metadata.xml'
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
'android/gradlew'
).
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'android'
)
.
childFile
(
'gradle.properties'
)
.
createSync
(
recursive:
true
);
fileSystem
.
file
(
'android/build.gradle'
)
.
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'android'
)
.
childDirectory
(
'app'
)
.
childFile
(
'build.gradle'
)
...
...
@@ -1224,7 +1240,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
AndroidStudio:
()
=>
mockAndroidStudio
,
Artifacts:
()
=>
mockArtifacts
,
Cache:
()
=>
cache
,
Platform:
()
=>
android
,
FileSystem:
()
=>
fileSystem
,
...
...
@@ -1232,6 +1247,12 @@ void main() {
});
testUsingContext
(
'honors --no-android-gradle-daemon setting'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/android/gradlew'
,
...
...
@@ -1250,10 +1271,8 @@ void main() {
fileSystem
.
directory
(
'android'
)
.
childFile
(
'gradle.properties'
)
.
createSync
(
recursive:
true
);
fileSystem
.
file
(
'android/build.gradle'
)
.
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'android'
)
.
childDirectory
(
'app'
)
.
childFile
(
'build.gradle'
)
...
...
@@ -1280,7 +1299,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
AndroidStudio:
()
=>
mockAndroidStudio
,
Artifacts:
()
=>
Artifacts
.
test
(),
Cache:
()
=>
cache
,
Platform:
()
=>
android
,
FileSystem:
()
=>
fileSystem
,
...
...
@@ -1288,6 +1306,12 @@ void main() {
});
testUsingContext
(
'build aar uses selected local engine with arm32 ABI'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(
localEngine:
'out/android_arm'
),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/.android/gradlew'
,
...
...
@@ -1309,14 +1333,6 @@ void main() {
exitCode:
0
,
));
when
(
mockArtifacts
.
getArtifactPath
(
Artifact
.
flutterFramework
,
platform:
TargetPlatform
.
android_arm
,
mode:
anyNamed
(
'mode'
),
environmentType:
anyNamed
(
'environmentType'
),
)).
thenReturn
(
'engine'
);
when
(
mockArtifacts
.
engineOutPath
).
thenReturn
(
fileSystem
.
path
.
join
(
'out'
,
'android_arm'
));
fileSystem
.
file
(
'out/android_arm/flutter_embedding_release.pom'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
...
...
@@ -1345,15 +1361,11 @@ void main() {
fileSystem
.
directory
(
'.android/gradle'
)
.
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'.android/gradle/wrapper'
)
.
createSync
(
recursive:
true
);
fileSystem
.
file
(
'.android/gradlew'
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
'.android/gradle.properties'
)
.
writeAsStringSync
(
'irrelevant'
);
fileSystem
.
file
(
'.android/build.gradle'
)
.
createSync
(
recursive:
true
);
...
...
@@ -1376,7 +1388,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
AndroidStudio:
()
=>
mockAndroidStudio
,
Artifacts:
()
=>
mockArtifacts
,
Cache:
()
=>
cache
,
Platform:
()
=>
android
,
FileSystem:
()
=>
fileSystem
,
...
...
@@ -1384,6 +1395,12 @@ void main() {
});
testUsingContext
(
'build aar uses selected local engine with x64 ABI'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(
localEngine:
'out/android_arm64'
),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/.android/gradlew'
,
...
...
@@ -1405,14 +1422,6 @@ void main() {
exitCode:
0
,
));
when
(
mockArtifacts
.
getArtifactPath
(
Artifact
.
flutterFramework
,
platform:
anyNamed
(
'platform'
),
mode:
anyNamed
(
'mode'
),
environmentType:
anyNamed
(
'environmentType'
),
)).
thenReturn
(
'engine'
);
when
(
mockArtifacts
.
engineOutPath
).
thenReturn
(
fileSystem
.
path
.
join
(
'out'
,
'android_arm64'
));
fileSystem
.
file
(
'out/android_arm64/flutter_embedding_release.pom'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
...
...
@@ -1441,18 +1450,13 @@ void main() {
fileSystem
.
directory
(
'.android/gradle'
)
.
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'.android/gradle/wrapper'
)
.
createSync
(
recursive:
true
);
fileSystem
.
file
(
'.android/gradlew'
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
'.android/gradle.properties'
)
.
writeAsStringSync
(
'irrelevant'
);
fileSystem
.
file
(
'.android/build.gradle'
)
.
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'build/outputs/repo'
).
createSync
(
recursive:
true
);
await
builder
.
buildGradleAar
(
...
...
@@ -1473,7 +1477,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
AndroidStudio:
()
=>
mockAndroidStudio
,
Artifacts:
()
=>
mockArtifacts
,
Cache:
()
=>
cache
,
Platform:
()
=>
android
,
FileSystem:
()
=>
fileSystem
,
...
...
@@ -1481,6 +1484,12 @@ void main() {
});
testUsingContext
(
'build aar uses selected local engine with x86 ABI'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(
localEngine:
'out/android_x86'
),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/.android/gradlew'
,
...
...
@@ -1502,14 +1511,6 @@ void main() {
exitCode:
0
,
));
when
(
mockArtifacts
.
getArtifactPath
(
Artifact
.
flutterFramework
,
platform:
anyNamed
(
'platform'
),
mode:
anyNamed
(
'mode'
),
environmentType:
anyNamed
(
'environmentType'
),
)).
thenReturn
(
'engine'
);
when
(
mockArtifacts
.
engineOutPath
).
thenReturn
(
fileSystem
.
path
.
join
(
'out'
,
'android_x86'
));
fileSystem
.
file
(
'out/android_x86/flutter_embedding_release.pom'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
...
...
@@ -1538,18 +1539,13 @@ void main() {
fileSystem
.
directory
(
'.android/gradle'
)
.
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'.android/gradle/wrapper'
)
.
createSync
(
recursive:
true
);
fileSystem
.
file
(
'.android/gradlew'
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
'.android/gradle.properties'
)
.
writeAsStringSync
(
'irrelevant'
);
fileSystem
.
file
(
'.android/build.gradle'
)
.
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'build/outputs/repo'
).
createSync
(
recursive:
true
);
await
builder
.
buildGradleAar
(
...
...
@@ -1570,7 +1566,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
AndroidStudio:
()
=>
mockAndroidStudio
,
Artifacts:
()
=>
mockArtifacts
,
Cache:
()
=>
cache
,
Platform:
()
=>
android
,
FileSystem:
()
=>
fileSystem
,
...
...
@@ -1578,6 +1573,12 @@ void main() {
});
testUsingContext
(
'build aar uses selected local engine on x64 ABI'
,
()
async
{
final
AndroidGradleBuilder
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
processManager
,
fileSystem:
fileSystem
,
artifacts:
Artifacts
.
test
(
localEngine:
'out/android_x64'
),
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/.android/gradlew'
,
...
...
@@ -1599,14 +1600,6 @@ void main() {
exitCode:
0
,
));
when
(
mockArtifacts
.
getArtifactPath
(
Artifact
.
flutterFramework
,
platform:
anyNamed
(
'platform'
),
mode:
anyNamed
(
'mode'
),
environmentType:
anyNamed
(
'environmentType'
),
)).
thenReturn
(
'engine'
);
when
(
mockArtifacts
.
engineOutPath
).
thenReturn
(
fileSystem
.
path
.
join
(
'out'
,
'android_x64'
));
fileSystem
.
file
(
'out/android_x64/flutter_embedding_release.pom'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
...
...
@@ -1635,18 +1628,13 @@ void main() {
fileSystem
.
directory
(
'.android/gradle'
)
.
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'.android/gradle/wrapper'
)
.
createSync
(
recursive:
true
);
fileSystem
.
file
(
'.android/gradlew'
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
'.android/gradle.properties'
)
.
writeAsStringSync
(
'irrelevant'
);
fileSystem
.
file
(
'.android/build.gradle'
)
.
createSync
(
recursive:
true
);
fileSystem
.
directory
(
'build/outputs/repo'
).
createSync
(
recursive:
true
);
await
builder
.
buildGradleAar
(
...
...
@@ -1667,7 +1655,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
AndroidStudio:
()
=>
mockAndroidStudio
,
Artifacts:
()
=>
mockArtifacts
,
Cache:
()
=>
cache
,
Platform:
()
=>
android
,
FileSystem:
()
=>
fileSystem
,
...
...
@@ -1686,4 +1673,3 @@ FakePlatform fakePlatform(String name) {
class
MockAndroidSdk
extends
Mock
implements
AndroidSdk
{}
class
MockAndroidStudio
extends
Mock
implements
AndroidStudio
{}
class
MockLocalEngineArtifacts
extends
Mock
implements
LocalEngineArtifacts
{}
packages/flutter_tools/test/general.shard/android/gradle_test.dart
View file @
bfcb43d2
...
...
@@ -860,7 +860,12 @@ flutter:
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[]);
mockAndroidSdk
=
MockAndroidSdk
();
when
(
mockAndroidSdk
.
directory
).
thenReturn
(
fs
.
directory
(
'irrelevant'
));
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
fakeProcessManager
,
fileSystem:
fs
);
builder
=
AndroidGradleBuilder
(
logger:
logger
,
processManager:
fakeProcessManager
,
fileSystem:
fs
,
artifacts:
Artifacts
.
test
(),
);
});
testUsingContext
(
'calls gradle'
,
()
async
{
...
...
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