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
bf4a5484
Unverified
Commit
bf4a5484
authored
Jan 14, 2021
by
Jonah Williams
Committed by
GitHub
Jan 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] no-op maven artifacts if Android SDK is absent (#73957)
parent
f1718bcf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
16 deletions
+34
-16
cache.dart
packages/flutter_tools/lib/src/cache.dart
+5
-0
cache_test.dart
packages/flutter_tools/test/general.shard/cache_test.dart
+29
-16
No files found.
packages/flutter_tools/lib/src/cache.dart
View file @
bf4a5484
...
...
@@ -1136,6 +1136,8 @@ class AndroidGenSnapshotArtifacts extends EngineCachedArtifact {
}
/// A cached artifact containing the Maven dependencies used to build Android projects.
///
/// This is a no-op if the android SDK is not available.
class
AndroidMavenArtifacts
extends
ArtifactSet
{
AndroidMavenArtifacts
(
this
.
cache
,
{
@required
Platform
platform
,
...
...
@@ -1152,6 +1154,9 @@ class AndroidMavenArtifacts extends ArtifactSet {
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
if
(
globals
.
androidSdk
==
null
)
{
return
;
}
final
Directory
tempDir
=
cache
.
getRoot
().
createTempSync
(
'flutter_gradle_wrapper.'
,
);
...
...
packages/flutter_tools/test/general.shard/cache_test.dart
View file @
bf4a5484
...
...
@@ -5,7 +5,7 @@
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:file_testing/file_testing.dart'
;
import
'package:flutter_tools/src/android/
gradle_utils
.dart'
;
import
'package:flutter_tools/src/android/
android_sdk
.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
show
InternetAddress
,
SocketException
;
import
'package:flutter_tools/src/base/io.dart'
;
...
...
@@ -653,24 +653,23 @@ void main() {
group
(
'AndroidMavenArtifacts'
,
()
{
MemoryFileSystem
memoryFileSystem
;
MockProcessManager
processManager
;
Cache
cache
;
setUp
(()
{
memoryFileSystem
=
MemoryFileSystem
.
test
();
processManager
=
MockProcessManager
();
cache
=
Cache
.
test
(
fileSystem:
memoryFileSystem
,
processManager:
FakeProcessManager
.
any
(),
);
});
testWithoutContext
(
'development artifact'
,
()
async
{
testWithoutContext
(
'
AndroidMavenArtifacts has a specified
development artifact'
,
()
async
{
final
AndroidMavenArtifacts
mavenArtifacts
=
AndroidMavenArtifacts
(
cache
,
platform:
FakePlatform
(
operatingSystem:
'linux'
));
expect
(
mavenArtifacts
.
developmentArtifact
,
DevelopmentArtifact
.
androidMaven
);
});
testUsingContext
(
'update'
,
()
async
{
testUsingContext
(
'AndroidMavenArtifacts can invoke Gradle resolve dependencies if Android SDK is present'
,
()
async
{
Cache
.
flutterRoot
=
''
;
final
AndroidMavenArtifacts
mavenArtifacts
=
AndroidMavenArtifacts
(
cache
,
platform:
FakePlatform
(
operatingSystem:
'linux'
));
expect
(
await
mavenArtifacts
.
isUpToDate
(
memoryFileSystem
),
isFalse
);
...
...
@@ -678,16 +677,28 @@ void main() {
gradleWrapperDir
.
childFile
(
'gradlew'
).
writeAsStringSync
(
'irrelevant'
);
gradleWrapperDir
.
childFile
(
'gradlew.bat'
).
writeAsStringSync
(
'irrelevant'
);
when
(
processManager
.
run
(
any
,
environment:
captureAnyNamed
(
'environment'
)))
.
thenAnswer
((
Invocation
invocation
)
{
final
List
<
String
>
args
=
invocation
.
positionalArguments
[
0
]
as
List
<
String
>;
expect
(
args
.
length
,
6
);
expect
(
args
[
1
],
'-b'
);
expect
(
args
[
2
].
endsWith
(
'resolve_dependencies.gradle'
),
isTrue
);
expect
(
args
[
5
],
'resolveDependencies'
);
expect
(
invocation
.
namedArguments
[
#environment
],
gradleEnvironment
);
return
Future
<
ProcessResult
>.
value
(
ProcessResult
(
0
,
0
,
''
,
''
));
});
await
mavenArtifacts
.
update
(
MockArtifactUpdater
(),
BufferLogger
.
test
(),
memoryFileSystem
,
MockOperatingSystemUtils
());
expect
(
await
mavenArtifacts
.
isUpToDate
(
memoryFileSystem
),
isFalse
);
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
cache
,
FileSystem:
()
=>
memoryFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'/cache/bin/cache/flutter_gradle_wrapper.rand0/gradlew'
,
'-b'
,
'packages/flutter_tools/gradle/resolve_dependencies.gradle'
,
'--project-cache-dir'
,
'cache/bin/cache/flutter_gradle_wrapper.rand0'
,
'resolveDependencies'
,
])
]),
AndroidSdk:
()
=>
FakeAndroidSdk
()
});
testUsingContext
(
'AndroidMavenArtifacts is a no-op if the Android SDK is absent'
,
()
async
{
final
AndroidMavenArtifacts
mavenArtifacts
=
AndroidMavenArtifacts
(
cache
,
platform:
FakePlatform
(
operatingSystem:
'linux'
));
expect
(
await
mavenArtifacts
.
isUpToDate
(
memoryFileSystem
),
isFalse
);
await
mavenArtifacts
.
update
(
MockArtifactUpdater
(),
BufferLogger
.
test
(),
memoryFileSystem
,
MockOperatingSystemUtils
());
...
...
@@ -695,7 +706,8 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
cache
,
FileSystem:
()
=>
memoryFileSystem
,
ProcessManager:
()
=>
processManager
,
ProcessManager:
()
=>
FakeProcessManager
.
list
(<
FakeCommand
>[]),
AndroidSdk:
()
=>
null
// Android SDK was not located.
});
});
}
...
...
@@ -782,3 +794,4 @@ class FakeCache extends Cache {
return
stampFile
;
}
}
class
FakeAndroidSdk
extends
Fake
implements
AndroidSdk
{}
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