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
fe9e8191
Unverified
Commit
fe9e8191
authored
Mar 08, 2023
by
Reid Baker
Committed by
GitHub
Mar 08, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create configOnly flag for android (#121904)
Create configOnly flag for android
parent
a9700ffd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
109 additions
and
4 deletions
+109
-4
android_builder.dart
packages/flutter_tools/lib/src/android/android_builder.dart
+2
-0
gradle.dart
packages/flutter_tools/lib/src/android/gradle.dart
+21
-4
build_apk.dart
packages/flutter_tools/lib/src/commands/build_apk.dart
+6
-0
android_gradle_builder_test.dart
...st/general.shard/android/android_gradle_builder_test.dart
+13
-0
flutter_build_config_only_test.dart
...est/integration.shard/flutter_build_config_only_test.dart
+65
-0
android_common.dart
packages/flutter_tools/test/src/android_common.dart
+2
-0
No files found.
packages/flutter_tools/lib/src/android/android_builder.dart
View file @
fe9e8191
...
...
@@ -27,6 +27,7 @@ abstract class AndroidBuilder {
required
FlutterProject
project
,
required
AndroidBuildInfo
androidBuildInfo
,
required
String
target
,
bool
configOnly
=
false
,
});
/// Builds an App Bundle artifact.
...
...
@@ -36,5 +37,6 @@ abstract class AndroidBuilder {
required
String
target
,
bool
validateDeferredComponents
=
true
,
bool
deferredComponentsEnabled
=
false
,
bool
configOnly
=
false
,
});
}
packages/flutter_tools/lib/src/android/gradle.dart
View file @
fe9e8191
...
...
@@ -181,6 +181,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
required
FlutterProject
project
,
required
AndroidBuildInfo
androidBuildInfo
,
required
String
target
,
bool
configOnly
=
false
,
})
async
{
await
buildGradleApp
(
project:
project
,
...
...
@@ -188,6 +189,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
target:
target
,
isBuildingBundle:
false
,
localGradleErrors:
gradleErrors
,
configOnly:
configOnly
,
);
}
...
...
@@ -199,6 +201,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
required
String
target
,
bool
validateDeferredComponents
=
true
,
bool
deferredComponentsEnabled
=
false
,
bool
configOnly
=
false
,
})
async
{
await
buildGradleApp
(
project:
project
,
...
...
@@ -208,6 +211,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
localGradleErrors:
gradleErrors
,
validateDeferredComponents:
validateDeferredComponents
,
deferredComponentsEnabled:
deferredComponentsEnabled
,
configOnly:
configOnly
,
);
}
...
...
@@ -225,6 +229,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
required
String
target
,
required
bool
isBuildingBundle
,
required
List
<
GradleHandledError
>
localGradleErrors
,
required
bool
configOnly
,
bool
validateDeferredComponents
=
true
,
bool
deferredComponentsEnabled
=
false
,
int
retry
=
0
,
...
...
@@ -249,8 +254,22 @@ class AndroidGradleBuilder implements AndroidBuilder {
}
// The default Gradle script reads the version name and number
// from the local.properties file.
updateLocalProperties
(
project:
project
,
buildInfo:
androidBuildInfo
.
buildInfo
);
updateLocalProperties
(
project:
project
,
buildInfo:
androidBuildInfo
.
buildInfo
);
final
List
<
String
>
command
=
<
String
>[
// This does more than get gradlewrapper. It creates the file, ensures it
// exists and verifies the file is executable.
_gradleUtils
.
getExecutable
(
project
),
];
// All automatically created files should exist.
if
(
configOnly
)
{
_logger
.
printStatus
(
'Config complete.'
);
return
;
}
// Assembly work starts here.
final
BuildInfo
buildInfo
=
androidBuildInfo
.
buildInfo
;
final
String
assembleTask
=
isBuildingBundle
?
getBundleTaskFor
(
buildInfo
)
...
...
@@ -260,9 +279,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
"Running Gradle task '
$assembleTask
'..."
,
);
final
List
<
String
>
command
=
<
String
>[
_gradleUtils
.
getExecutable
(
project
),
];
if
(
_logger
.
isVerbose
)
{
command
.
add
(
'--full-stacktrace'
);
command
.
add
(
'--info'
);
...
...
@@ -428,6 +444,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
localGradleErrors:
localGradleErrors
,
retry:
retry
,
maxRetries:
maxRetries
,
configOnly:
configOnly
,
);
final
String
successEventLabel
=
'gradle-
${detectedGradleError!.eventLabel}
-success'
;
BuildEvent
(
successEventLabel
,
type:
'gradle'
,
flutterUsage:
_usage
).
send
();
...
...
packages/flutter_tools/lib/src/commands/build_apk.dart
View file @
fe9e8191
...
...
@@ -43,6 +43,9 @@ class BuildApkCommand extends BuildSubCommand {
help:
'Whether to split the APKs per ABIs. '
'To learn more, see: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split'
,
)
..
addFlag
(
'config-only'
,
help:
'Generate build files used by flutter but '
'do not build any artifacts.'
)
..
addMultiOption
(
'target-platform'
,
defaultsTo:
<
String
>[
'android-arm'
,
'android-arm64'
,
'android-x64'
],
allowed:
<
String
>[
'android-arm'
,
'android-arm64'
,
'android-x86'
,
'android-x64'
],
...
...
@@ -57,6 +60,8 @@ class BuildApkCommand extends BuildSubCommand {
@override
DeprecationBehavior
get
deprecationBehavior
=>
boolArgDeprecated
(
'ignore-deprecation'
)
?
DeprecationBehavior
.
ignore
:
DeprecationBehavior
.
exit
;
bool
get
configOnly
=>
boolArg
(
'config-only'
)
??
false
;
@override
Future
<
Set
<
DevelopmentArtifact
>>
get
requiredArtifacts
async
=>
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
androidGenSnapshot
,
...
...
@@ -112,6 +117,7 @@ class BuildApkCommand extends BuildSubCommand {
project:
FlutterProject
.
current
(),
target:
targetFile
,
androidBuildInfo:
androidBuildInfo
,
configOnly:
configOnly
,
);
return
FlutterCommandResult
.
success
();
}
...
...
packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart
View file @
fe9e8191
...
...
@@ -92,6 +92,7 @@ void main() {
),
target:
'lib/main.dart'
,
isBuildingBundle:
false
,
configOnly:
false
,
localGradleErrors:
<
GradleHandledError
>[
GradleHandledError
(
test:
(
String
line
)
{
...
...
@@ -187,6 +188,7 @@ void main() {
),
target:
'lib/main.dart'
,
isBuildingBundle:
false
,
configOnly:
false
,
localGradleErrors:
<
GradleHandledError
>[],
);
expect
(
processManager
,
hasNoRemainingExpectations
);
...
...
@@ -256,6 +258,7 @@ void main() {
),
target:
'lib/main.dart'
,
isBuildingBundle:
false
,
configOnly:
false
,
localGradleErrors:
<
GradleHandledError
>[
GradleHandledError
(
test:
(
String
line
)
{
...
...
@@ -350,6 +353,7 @@ void main() {
),
target:
'lib/main.dart'
,
isBuildingBundle:
false
,
configOnly:
false
,
localGradleErrors:
<
GradleHandledError
>[
GradleHandledError
(
test:
(
String
line
)
{
...
...
@@ -441,6 +445,7 @@ void main() {
),
target:
'lib/main.dart'
,
isBuildingBundle:
false
,
configOnly:
false
,
localGradleErrors:
const
<
GradleHandledError
>[],
);
},
throwsProcessException
());
...
...
@@ -520,6 +525,7 @@ void main() {
),
target:
'lib/main.dart'
,
isBuildingBundle:
false
,
configOnly:
false
,
localGradleErrors:
<
GradleHandledError
>[
GradleHandledError
(
test:
(
String
line
)
{
...
...
@@ -636,6 +642,7 @@ void main() {
),
target:
'lib/main.dart'
,
isBuildingBundle:
false
,
configOnly:
false
,
localGradleErrors:
<
GradleHandledError
>[],
);
...
...
@@ -704,6 +711,7 @@ void main() {
),
target:
'lib/main.dart'
,
isBuildingBundle:
false
,
configOnly:
false
,
localGradleErrors:
const
<
GradleHandledError
>[],
);
...
...
@@ -963,6 +971,7 @@ void main() {
),
target:
'lib/main.dart'
,
isBuildingBundle:
false
,
configOnly:
false
,
localGradleErrors:
const
<
GradleHandledError
>[],
);
},
throwsToolExit
());
...
...
@@ -1039,6 +1048,7 @@ void main() {
),
target:
'lib/main.dart'
,
isBuildingBundle:
false
,
configOnly:
false
,
localGradleErrors:
const
<
GradleHandledError
>[],
);
},
throwsToolExit
());
...
...
@@ -1115,6 +1125,7 @@ void main() {
),
target:
'lib/main.dart'
,
isBuildingBundle:
false
,
configOnly:
false
,
localGradleErrors:
const
<
GradleHandledError
>[],
);
},
throwsToolExit
());
...
...
@@ -1192,6 +1203,7 @@ void main() {
),
target:
'lib/main.dart'
,
isBuildingBundle:
false
,
configOnly:
false
,
localGradleErrors:
const
<
GradleHandledError
>[],
);
},
throwsToolExit
());
...
...
@@ -1250,6 +1262,7 @@ void main() {
),
target:
'lib/main.dart'
,
isBuildingBundle:
false
,
configOnly:
false
,
localGradleErrors:
const
<
GradleHandledError
>[],
);
},
throwsToolExit
());
...
...
packages/flutter_tools/test/integration.shard/flutter_build_config_only_test.dart
0 → 100644
View file @
fe9e8191
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:file_testing/file_testing.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'../src/common.dart'
;
import
'test_utils.dart'
;
// Test that configOnly creates the gradlew file and does not assemble and app.
void
main
(
)
{
late
Directory
tempDir
;
late
String
flutterBin
;
late
Directory
exampleAppDir
;
setUp
(()
async
{
tempDir
=
createResolvedTempDirectorySync
(
'flutter_build_test.'
);
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
,
);
exampleAppDir
=
tempDir
.
childDirectory
(
'bbb'
).
childDirectory
(
'example'
);
processManager
.
runSync
(<
String
>[
flutterBin
,
...
getLocalEngineArguments
(),
'create'
,
'--template=plugin'
,
'--platforms=android'
,
'bbb'
,
],
workingDirectory:
tempDir
.
path
);
});
tearDown
(()
async
{
tryToDelete
(
tempDir
);
});
test
(
'flutter build apk --config-only should create gradlew and not assemble'
,
()
async
{
final
File
gradleFile
=
fileSystem
.
directory
(
exampleAppDir
)
.
childDirectory
(
'android'
)
.
childFile
(
platform
.
isWindows
?
'gradlew.bat'
:
'gradlew'
);
// Ensure file is gone prior to configOnly running.
await
gradleFile
.
delete
();
final
ProcessResult
result
=
processManager
.
runSync
(<
String
>[
flutterBin
,
...
getLocalEngineArguments
(),
'build'
,
'apk'
,
'--target-platform=android-arm'
,
'--config-only'
,
],
workingDirectory:
exampleAppDir
.
path
);
expect
(
gradleFile
,
exists
);
expect
(
result
.
stdout
,
contains
(
RegExp
(
r'Config complete'
)));
expect
(
result
.
stdout
,
isNot
(
contains
(
RegExp
(
r'Running Gradle task'
))));
},
);
}
packages/flutter_tools/test/src/android_common.dart
View file @
fe9e8191
...
...
@@ -24,6 +24,7 @@ class FakeAndroidBuilder implements AndroidBuilder {
required
FlutterProject
project
,
required
AndroidBuildInfo
androidBuildInfo
,
required
String
target
,
bool
configOnly
=
false
,
})
async
{}
@override
...
...
@@ -33,6 +34,7 @@ class FakeAndroidBuilder implements AndroidBuilder {
required
String
target
,
bool
validateDeferredComponents
=
true
,
bool
deferredComponentsEnabled
=
false
,
bool
configOnly
=
false
,
})
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