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
76957c9d
Unverified
Commit
76957c9d
authored
Nov 05, 2019
by
Emmanuel Garcia
Committed by
GitHub
Nov 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build aar prints how to consume the artifacts (#44127)
parent
7957c569
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
121 additions
and
23 deletions
+121
-23
gradle.dart
packages/flutter_tools/lib/src/android/gradle.dart
+39
-0
gradle_test.dart
...flutter_tools/test/general.shard/android/gradle_test.dart
+82
-23
No files found.
packages/flutter_tools/lib/src/android/gradle.dart
View file @
76957c9d
...
...
@@ -545,6 +545,45 @@ Future<void> buildGradleAar({
'
$successMark
Built
${fs.path.relative(repoDirectory.path)}
.'
,
color:
TerminalColor
.
green
,
);
_printHowToConsumeAar
(
buildMode:
androidBuildInfo
.
buildInfo
.
modeName
,
androidPackage:
project
.
manifest
.
androidPackage
,
repoPath:
repoDirectory
.
path
,
);
}
/// Prints how to consume the AAR from a host app.
void
_printHowToConsumeAar
(
{
@required
String
buildMode
,
@required
String
androidPackage
,
@required
String
repoPath
,
})
{
assert
(
buildMode
!=
null
);
assert
(
androidPackage
!=
null
);
assert
(
repoPath
!=
null
);
printStatus
(
'''
${terminal.bolden('Consuming the Module')}
1. Open
${fs.path.join('<host>', 'app', 'build.gradle')}
2. Ensure you have the repositories configured, otherwise add them:
repositories {
maven {
url '
$repoPath
'
}
maven {
url '
http:
//download.flutter.io'
}
}
3
.
Make
the
host
app
depend
on
the
$buildMode
module:
dependencies
{
$
{
buildMode
}
Implementation
'
$androidPackage
:flutter_
$buildMode
:1.0'
}
To
learn
more
,
visit
https:
//flutter.dev/go/build-aar''');
}
String
_hex
(
List
<
int
>
bytes
)
{
...
...
packages/flutter_tools/test/general.shard/android/gradle_test.dart
View file @
76957c9d
...
...
@@ -1501,56 +1501,115 @@ plugin2=${plugin2.path}
ProcessManager:
()
=>
mockProcessManager
,
});
testUsingContext
(
'indicates how to consume an AAR'
,
()
async
{
final
File
manifestFile
=
fs
.
file
(
'pubspec.yaml'
);
manifestFile
.
createSync
(
recursive:
true
);
manifestFile
.
writeAsStringSync
(
'''
flutter:
module:
androidPackage: com.example.test
'''
);
fs
.
file
(
'.android/gradlew'
).
createSync
(
recursive:
true
);
fs
.
file
(
'.android/gradle.properties'
)
.
writeAsStringSync
(
'irrelevant'
);
fs
.
file
(
'.android/build.gradle'
)
.
createSync
(
recursive:
true
);
// Let any process start. Assert after.
when
(
mockProcessManager
.
run
(
any
,
environment:
anyNamed
(
'environment'
),
workingDirectory:
anyNamed
(
'workingDirectory'
),
)).
thenAnswer
((
_
)
async
=>
ProcessResult
(
1
,
0
,
''
,
''
));
fs
.
directory
(
'build/outputs/repo'
).
createSync
(
recursive:
true
);
await
buildGradleAar
(
androidBuildInfo:
const
AndroidBuildInfo
(
BuildInfo
(
BuildMode
.
release
,
null
)),
project:
FlutterProject
.
current
(),
outputDir:
fs
.
directory
(
'build/'
),
target:
''
,
);
final
BufferLogger
logger
=
context
.
get
<
Logger
>();
expect
(
logger
.
statusText
,
contains
(
'Built build/outputs/repo'
),
);
expect
(
logger
.
statusText
,
contains
(
'''
Consuming the Module
1. Open <host>/app/build.gradle
2. Ensure you have the repositories configured, otherwise add them:
repositories {
maven {
url '
build
/
outputs
/
repo
'
}
maven {
url '
http:
//download.flutter.io'
}
}
3
.
Make
the
host
app
depend
on
the
release
module:
dependencies
{
releaseImplementation
'com.example.test:flutter_release:1.0'
}
To
learn
more
,
visit
https:
//flutter.dev/go/build-aar'''));
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
AndroidStudio:
()
=>
mockAndroidStudio
,
Artifacts:
()
=>
mockArtifacts
,
Cache:
()
=>
cache
,
Platform:
()
=>
android
,
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
mockProcessManager
,
});
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
(
'p
ath/to/project/p
ubspec.yaml'
);
final
File
manifestFile
=
fs
.
file
(
'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'
);
final
File
gradlew
=
fs
.
file
(
'.android/gradlew'
);
gradlew
.
createSync
(
recursive:
true
);
fs
.
file
(
'
path/to/project/
.android/gradle.properties'
)
fs
.
file
(
'.android/gradle.properties'
)
.
writeAsStringSync
(
'irrelevant'
);
fs
.
file
(
'
path/to/project/
.android/build.gradle'
)
fs
.
file
(
'.android/build.gradle'
)
.
createSync
(
recursive:
true
);
when
(
mockProcessManager
.
run
(
<
String
>
[
'
/path/to/project/
.android/gradlew'
,
'-v'
],
<
String
>
[
'.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'
;
)).
thenAnswer
((
_
)
async
=>
ProcessResult
(
1
,
0
,
'5.1.1'
,
''
));
// Let any process start. Assert after.
when
(
mockProcessManager
.
run
(
any
,
environment:
anyNamed
(
'environment'
),
workingDirectory:
anyNamed
(
'workingDirectory'
),
)).
thenAnswer
(
(
_
)
async
=>
ProcessResult
(
1
,
0
,
''
,
''
),
);
)).
thenAnswer
((
_
)
async
=>
ProcessResult
(
1
,
0
,
''
,
''
));
fs
.
directory
(
'build/outputs/repo'
).
createSync
(
recursive:
true
);
await
buildGradleAar
(
...
...
@@ -1566,7 +1625,7 @@ plugin2=${plugin2.path}
workingDirectory:
anyNamed
(
'workingDirectory'
)),
).
captured
.
last
;
expect
(
actualGradlewCall
,
contains
(
'/
path/to/project/
.android/gradlew'
));
expect
(
actualGradlewCall
,
contains
(
'/.android/gradlew'
));
expect
(
actualGradlewCall
,
contains
(
'-PlocalEngineOut=out/android_arm'
));
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
...
...
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