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
577c2fc4
Commit
577c2fc4
authored
Jun 25, 2019
by
Josh Burton
Committed by
Emmanuel Garcia
Jun 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensures flutter jar is added to all build types on plugin projects (#34573)
parent
c7408be1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
22 deletions
+64
-22
gradle_plugin_light_apk_test.dart
dev/devicelab/bin/tasks/gradle_plugin_light_apk_test.dart
+11
-0
apk_utils.dart
dev/devicelab/lib/framework/apk_utils.dart
+36
-0
flutter.gradle
packages/flutter_tools/gradle/flutter.gradle
+17
-22
No files found.
dev/devicelab/bin/tasks/gradle_plugin_light_apk_test.dart
View file @
577c2fc4
...
...
@@ -164,6 +164,17 @@ Future<void> main() async {
await
project
.
runGradleTask
(
'assembleBeta'
);
});
await
runProjectTest
((
FlutterProject
project
)
async
{
section
(
'gradlew assembleLocal (plugin with custom build type)'
);
await
project
.
addCustomBuildType
(
'local'
,
initWith:
'debug'
);
await
project
.
addGlobalBuildType
(
'local'
,
initWith:
'debug'
);
section
(
'Add plugin'
);
await
project
.
addPlugin
(
'path_provider'
);
await
project
.
getPackages
();
await
project
.
runGradleTask
(
'assembleLocal'
);
});
await
runProjectTest
((
FlutterProject
project
)
async
{
section
(
'gradlew assembleFreeDebug (product flavor)'
);
await
project
.
addProductFlavors
(<
String
>[
'free'
]);
...
...
dev/devicelab/lib/framework/apk_utils.dart
View file @
577c2fc4
...
...
@@ -116,6 +116,42 @@ android {
'''
);
}
Future
<
void
>
addGlobalBuildType
(
String
name
,
{
String
initWith
})
async
{
final
File
buildScript
=
File
(
path
.
join
(
androidPath
,
'build.gradle'
),
);
buildScript
.
openWrite
(
mode:
FileMode
.
append
).
write
(
'''
subprojects {
afterEvaluate {
android {
buildTypes {
$name
{
initWith
$initWith
}
}
}
}
}
'''
);
}
Future
<
void
>
addPlugin
(
String
plugin
)
async
{
final
File
pubspec
=
File
(
path
.
join
(
rootPath
,
'pubspec.yaml'
));
String
content
=
await
pubspec
.
readAsString
();
content
=
content
.
replaceFirst
(
'
\n
dependencies:
\n
'
,
'
\n
dependencies:
\n
$plugin
:
\n
'
,
);
await
pubspec
.
writeAsString
(
content
,
flush:
true
);
}
Future
<
void
>
getPackages
()
async
{
await
inDirectory
(
Directory
(
rootPath
),
()
async
{
await
flutter
(
'pub'
,
options:
<
String
>[
'get'
]);
});
}
Future
<
void
>
addProductFlavors
(
Iterable
<
String
>
flavors
)
async
{
final
File
buildScript
=
File
(
path
.
join
(
androidPath
,
'app'
,
'build.gradle'
),
...
...
packages/flutter_tools/gradle/flutter.gradle
View file @
577c2fc4
...
...
@@ -223,8 +223,16 @@ class FlutterPlugin implements Plugin<Project> {
initWith
debug
}
}
pluginProject
.
android
.
buildTypes
.
each
{
def
buildMode
=
buildModeFor
(
it
)
addFlutterJarCompileOnlyDependency
(
pluginProject
,
it
.
name
,
project
.
files
(
flutterJar
?:
baseJar
[
buildMode
]
))
}
pluginProject
.
android
.
buildTypes
.
whenObjectAdded
{
def
buildMode
=
buildModeFor
(
it
)
addFlutterJarCompileOnlyDependency
(
pluginProject
,
it
.
name
,
project
.
files
(
flutterJar
?:
baseJar
[
buildMode
]
))
}
}
pluginProject
.
afterEvaluate
this
.&
addFlutterJarCompileOnlyDependency
}
else
{
project
.
logger
.
error
(
"Plugin project :$name not found. Please update settings.gradle."
)
}
...
...
@@ -292,33 +300,20 @@ class FlutterPlugin implements Plugin<Project> {
return
PLATFORM_ARM32
;
}
// TODO(blasten): Clean this up.
private
void
addFlutterJarCompileOnlyDependency
(
Project
project
)
{
private
void
addFlutterJarCompileOnlyDependency
(
Project
project
,
String
variantName
,
FileCollection
files
)
{
if
(
project
.
state
.
failure
)
{
return
}
project
.
dependencies
{
if
(
flutterJar
!=
null
)
{
String
configuration
;
if
(
project
.
getConfigurations
().
findByName
(
"compileOnly"
))
{
compileOnly
project
.
files
(
flutterJar
)
configuration
=
"${variantName}CompileOnly"
;
}
else
{
provided
project
.
files
(
flutterJar
)
}
}
else
{
assert
baseJar
[
"debug"
].
isFile
()
assert
baseJar
[
"profile"
].
isFile
()
assert
baseJar
[
"release"
].
isFile
()
if
(
project
.
getConfigurations
().
findByName
(
"debugCompileOnly"
))
{
debugCompileOnly
project
.
files
(
baseJar
[
"debug"
])
profileCompileOnly
project
.
files
(
baseJar
[
"profile"
])
releaseCompileOnly
project
.
files
(
baseJar
[
"release"
])
}
else
{
debugProvided
project
.
files
(
baseJar
[
"debug"
])
profileProvided
project
.
files
(
baseJar
[
"profile"
])
releaseProvided
project
.
files
(
baseJar
[
"release"
])
}
configuration
=
"${variantName}Provided"
;
}
add
(
configuration
,
files
)
}
}
...
...
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