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
4640690d
Unverified
Commit
4640690d
authored
Aug 28, 2019
by
xster
Committed by
GitHub
Aug 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
let flutter build aar use a local engine (#39312)
parent
9e4c3bd9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
0 deletions
+98
-0
gradle.dart
packages/flutter_tools/lib/src/android/gradle.dart
+6
-0
gradle_test.dart
...flutter_tools/test/general.shard/android/gradle_test.dart
+92
-0
No files found.
packages/flutter_tools/lib/src/android/gradle.dart
View file @
4640690d
...
...
@@ -549,6 +549,12 @@ Future<void> buildGradleAar({
.
map
(
getPlatformNameForAndroidArch
).
join
(
','
);
command
.
add
(
'-Ptarget-platform=
$targetPlatforms
'
);
}
if
(
artifacts
is
LocalEngineArtifacts
)
{
final
LocalEngineArtifacts
localEngineArtifacts
=
artifacts
;
printTrace
(
'Using local engine:
${localEngineArtifacts.engineOutPath}
'
);
command
.
add
(
'-PlocalEngineOut=
${localEngineArtifacts.engineOutPath}
'
);
}
command
.
add
(
aarTask
);
final
Stopwatch
sw
=
Stopwatch
()..
start
();
...
...
packages/flutter_tools/test/general.shard/android/gradle_test.dart
View file @
4640690d
...
...
@@ -3,8 +3,11 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:io'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/android/android_sdk.dart'
;
import
'package:flutter_tools/src/android/android_studio.dart'
;
import
'package:flutter_tools/src/android/gradle.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
...
...
@@ -20,6 +23,7 @@ import 'package:process/process.dart';
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/mocks.dart'
;
import
'../../src/pubspec_schema.dart'
;
void
main
(
)
{
...
...
@@ -843,6 +847,92 @@ flutter:
throwsA
(
predicate
<
Exception
>((
Exception
e
)
=>
e
is
ToolExit
)));
});
});
group
(
'gradle build'
,
()
{
MockAndroidSdk
mockAndroidSdk
;
MockAndroidStudio
mockAndroidStudio
;
MockLocalEngineArtifacts
mockArtifacts
;
MockProcessManager
mockProcessManager
;
FakePlatform
android
;
FileSystem
fs
;
setUp
(()
{
fs
=
MemoryFileSystem
();
mockAndroidSdk
=
MockAndroidSdk
();
mockAndroidStudio
=
MockAndroidStudio
();
mockArtifacts
=
MockLocalEngineArtifacts
();
mockProcessManager
=
MockProcessManager
();
android
=
fakePlatform
(
'android'
);
});
testUsingContext
(
'build aar uses selected local engine'
,
()
async
{
when
(
mockArtifacts
.
getArtifactPath
(
Artifact
.
flutterFramework
,
platform:
TargetPlatform
.
android_arm
,
mode:
anyNamed
(
'mode'
))).
thenReturn
(
'engine'
);
when
(
mockArtifacts
.
engineOutPath
).
thenReturn
(
fs
.
path
.
join
(
'out'
,
'android_arm'
));
final
File
manifestFile
=
fs
.
file
(
'path/to/project/pubspec.yaml'
);
manifestFile
.
createSync
(
recursive:
true
);
manifestFile
.
writeAsStringSync
(
'''
name: test
version: 1.0.0+1
dependencies:
flutter:
sdk: flutter
flutter:
module:
androidX: false
androidPackage: com.example.test
iosBundleIdentifier: com.example.test
'''
);
final
File
gradlew
=
fs
.
file
(
'path/to/project/.android/gradlew'
);
gradlew
.
createSync
(
recursive:
true
);
when
(
mockProcessManager
.
run
(
<
String
>
[
'/path/to/project/.android/gradlew'
,
'-v'
],
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
)).
thenAnswer
(
(
_
)
async
=>
ProcessResult
(
1
,
0
,
'5.1.1'
,
''
),
);
// write schemaData otherwise pubspec.yaml file can't be loaded
writeEmptySchemaFile
(
fs
);
fs
.
currentDirectory
=
'path/to/project'
;
// Let any process start. Assert after.
when
(
mockProcessManager
.
start
(
any
,
environment:
anyNamed
(
'environment'
),
workingDirectory:
anyNamed
(
'workingDirectory'
))
).
thenAnswer
((
Invocation
invocation
)
=>
Future
<
Process
>.
value
(
MockProcess
()));
fs
.
directory
(
'build/outputs/repo'
).
createSync
(
recursive:
true
);
await
buildGradleAar
(
androidBuildInfo:
const
AndroidBuildInfo
(
BuildInfo
(
BuildMode
.
release
,
null
)),
project:
FlutterProject
.
current
(),
outputDir:
'build/'
,
target:
''
);
final
List
<
String
>
actualGradlewCall
=
verify
(
mockProcessManager
.
start
(
captureAny
,
environment:
anyNamed
(
'environment'
),
workingDirectory:
anyNamed
(
'workingDirectory'
)),
).
captured
.
single
;
expect
(
actualGradlewCall
,
contains
(
'/path/to/project/.android/gradlew'
));
expect
(
actualGradlewCall
,
contains
(
'-PlocalEngineOut=out/android_arm'
));
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
AndroidStudio:
()
=>
mockAndroidStudio
,
Artifacts:
()
=>
mockArtifacts
,
ProcessManager:
()
=>
mockProcessManager
,
Platform:
()
=>
android
,
FileSystem:
()
=>
fs
,
});
});
}
/// Generates a fake app bundle at the location [directoryName]/[fileName].
...
...
@@ -864,3 +954,5 @@ class MockLocalEngineArtifacts extends Mock implements LocalEngineArtifacts {}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockXcodeProjectInterpreter
extends
Mock
implements
XcodeProjectInterpreter
{}
class
MockGradleProject
extends
Mock
implements
GradleProject
{}
class
MockitoAndroidSdk
extends
Mock
implements
AndroidSdk
{}
class
MockAndroidStudio
extends
Mock
implements
AndroidStudio
{}
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