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
418b8145
Commit
418b8145
authored
Dec 12, 2019
by
Sean Freiburg
Committed by
Flutter GitHub Bot
Dec 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add buildNumber param to "flutter build aar" command (#46291)
parent
354f80b8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
17 deletions
+49
-17
utils.dart
dev/devicelab/lib/framework/utils.dart
+2
-2
aar_init_script.gradle
packages/flutter_tools/gradle/aar_init_script.gradle
+9
-3
android_builder.dart
packages/flutter_tools/lib/src/android/android_builder.dart
+4
-0
gradle.dart
packages/flutter_tools/lib/src/android/gradle.dart
+8
-1
build_aar.dart
packages/flutter_tools/lib/src/commands/build_aar.dart
+15
-8
gradle_test.dart
...flutter_tools/test/general.shard/android/gradle_test.dart
+10
-3
android_common.dart
packages/flutter_tools/test/src/android_common.dart
+1
-0
No files found.
dev/devicelab/lib/framework/utils.dart
View file @
418b8145
...
@@ -623,14 +623,14 @@ Uri parseServiceUri(String line, {
...
@@ -623,14 +623,14 @@ Uri parseServiceUri(String line, {
/// Checks that the file exists, otherwise throws a [FileSystemException].
/// Checks that the file exists, otherwise throws a [FileSystemException].
void
checkFileExists
(
String
file
)
{
void
checkFileExists
(
String
file
)
{
if
(!
exists
(
File
(
file
)))
{
if
(!
exists
(
File
(
file
)))
{
throw
FileSystemException
(
'Expected file to exit.'
,
file
);
throw
FileSystemException
(
'Expected file to exi
s
t.'
,
file
);
}
}
}
}
/// Checks that the file does not exists, otherwise throws a [FileSystemException].
/// Checks that the file does not exists, otherwise throws a [FileSystemException].
void
checkFileNotExists
(
String
file
)
{
void
checkFileNotExists
(
String
file
)
{
if
(
exists
(
File
(
file
)))
{
if
(
exists
(
File
(
file
)))
{
throw
FileSystemException
(
'Expected file to
exi
t.'
,
file
);
throw
FileSystemException
(
'Expected file to
not exis
t.'
,
file
);
}
}
}
}
...
...
packages/flutter_tools/gradle/aar_init_script.gradle
View file @
418b8145
...
@@ -20,15 +20,20 @@ void configureProject(Project project, String outputDir) {
...
@@ -20,15 +20,20 @@ void configureProject(Project project, String outputDir) {
project
.
apply
plugin:
"maven"
project
.
apply
plugin:
"maven"
project
.
android
.
libraryVariants
.
all
{
variant
->
addAarTask
(
project
,
variant
)
}
// Snapshot versions include the timestamp in the artifact name.
// Snapshot versions include the timestamp in the artifact name.
// Therefore, remove the snapshot part, so new runs of `flutter build aar` overrides existing artifacts.
// Therefore, remove the snapshot part, so new runs of `flutter build aar` overrides existing artifacts.
// This version isn't relevant in Flutter since the pub version is used
// This version isn't relevant in Flutter since the pub version is used
// to resolve dependencies.
// to resolve dependencies.
project
.
version
=
project
.
version
.
replace
(
"-SNAPSHOT"
,
""
)
project
.
version
=
project
.
version
.
replace
(
"-SNAPSHOT"
,
""
)
if
(
project
.
hasProperty
(
"buildNumber"
))
{
project
.
version
=
project
.
property
(
"buildNumber"
)
}
project
.
android
.
libraryVariants
.
all
{
variant
->
addAarTask
(
project
,
variant
)
}
project
.
uploadArchives
{
project
.
uploadArchives
{
repositories
{
repositories
{
mavenDeployer
{
mavenDeployer
{
...
@@ -39,6 +44,7 @@ void configureProject(Project project, String outputDir) {
...
@@ -39,6 +44,7 @@ void configureProject(Project project, String outputDir) {
if
(!
project
.
property
(
"is-plugin"
).
toBoolean
())
{
if
(!
project
.
property
(
"is-plugin"
).
toBoolean
())
{
return
return
}
}
if
(
project
.
hasProperty
(
'localEngineOut'
))
{
if
(
project
.
hasProperty
(
'localEngineOut'
))
{
// TODO(egarciad): Support local engine.
// TODO(egarciad): Support local engine.
// This most likely requires refactoring `flutter.gradle`, so the logic can be reused.
// This most likely requires refactoring `flutter.gradle`, so the logic can be reused.
...
...
packages/flutter_tools/lib/src/android/android_builder.dart
View file @
418b8145
...
@@ -29,6 +29,7 @@ abstract class AndroidBuilder {
...
@@ -29,6 +29,7 @@ abstract class AndroidBuilder {
@required
Set
<
AndroidBuildInfo
>
androidBuildInfo
,
@required
Set
<
AndroidBuildInfo
>
androidBuildInfo
,
@required
String
target
,
@required
String
target
,
@required
String
outputDirectoryPath
,
@required
String
outputDirectoryPath
,
@required
String
buildNumber
,
});
});
/// Builds an APK artifact.
/// Builds an APK artifact.
...
@@ -57,6 +58,7 @@ class _AndroidBuilderImpl extends AndroidBuilder {
...
@@ -57,6 +58,7 @@ class _AndroidBuilderImpl extends AndroidBuilder {
@required
Set
<
AndroidBuildInfo
>
androidBuildInfo
,
@required
Set
<
AndroidBuildInfo
>
androidBuildInfo
,
@required
String
target
,
@required
String
target
,
@required
String
outputDirectoryPath
,
@required
String
outputDirectoryPath
,
@required
String
buildNumber
,
})
async
{
})
async
{
try
{
try
{
Directory
outputDirectory
=
Directory
outputDirectory
=
...
@@ -71,6 +73,7 @@ class _AndroidBuilderImpl extends AndroidBuilder {
...
@@ -71,6 +73,7 @@ class _AndroidBuilderImpl extends AndroidBuilder {
androidBuildInfo:
androidBuildInfo
,
androidBuildInfo:
androidBuildInfo
,
target:
target
,
target:
target
,
outputDirectory:
outputDirectory
,
outputDirectory:
outputDirectory
,
buildNumber:
buildNumber
,
);
);
}
}
printHowToConsumeAar
(
printHowToConsumeAar
(
...
@@ -80,6 +83,7 @@ class _AndroidBuilderImpl extends AndroidBuilder {
...
@@ -80,6 +83,7 @@ class _AndroidBuilderImpl extends AndroidBuilder {
}).
toSet
(),
}).
toSet
(),
androidPackage:
project
.
manifest
.
androidPackage
,
androidPackage:
project
.
manifest
.
androidPackage
,
repoDirectory:
getRepoDirectory
(
outputDirectory
),
repoDirectory:
getRepoDirectory
(
outputDirectory
),
buildNumber:
buildNumber
,
);
);
}
finally
{
}
finally
{
androidSdk
.
reinitialize
();
androidSdk
.
reinitialize
();
...
...
packages/flutter_tools/lib/src/android/gradle.dart
View file @
418b8145
...
@@ -477,11 +477,13 @@ Future<void> buildGradleApp({
...
@@ -477,11 +477,13 @@ Future<void> buildGradleApp({
/// * [project] is typically [FlutterProject.current()].
/// * [project] is typically [FlutterProject.current()].
/// * [androidBuildInfo] is the build configuration.
/// * [androidBuildInfo] is the build configuration.
/// * [outputDir] is the destination of the artifacts,
/// * [outputDir] is the destination of the artifacts,
/// * [buildNumber] is the build number of the output aar,
Future
<
void
>
buildGradleAar
({
Future
<
void
>
buildGradleAar
({
@required
FlutterProject
project
,
@required
FlutterProject
project
,
@required
AndroidBuildInfo
androidBuildInfo
,
@required
AndroidBuildInfo
androidBuildInfo
,
@required
String
target
,
@required
String
target
,
@required
Directory
outputDirectory
,
@required
Directory
outputDirectory
,
@required
String
buildNumber
,
})
async
{
})
async
{
assert
(
project
!=
null
);
assert
(
project
!=
null
);
assert
(
target
!=
null
);
assert
(
target
!=
null
);
...
@@ -491,6 +493,7 @@ Future<void> buildGradleAar({
...
@@ -491,6 +493,7 @@ Future<void> buildGradleAar({
if
(
androidSdk
==
null
)
{
if
(
androidSdk
==
null
)
{
exitWithNoSdkMessage
();
exitWithNoSdkMessage
();
}
}
final
FlutterManifest
manifest
=
project
.
manifest
;
final
FlutterManifest
manifest
=
project
.
manifest
;
if
(!
manifest
.
isModule
&&
!
manifest
.
isPlugin
)
{
if
(!
manifest
.
isModule
&&
!
manifest
.
isPlugin
)
{
throwToolExit
(
'AARs can only be built for plugin or module projects.'
);
throwToolExit
(
'AARs can only be built for plugin or module projects.'
);
...
@@ -517,6 +520,7 @@ Future<void> buildGradleAar({
...
@@ -517,6 +520,7 @@ Future<void> buildGradleAar({
'-Pflutter-root=
$flutterRoot
'
,
'-Pflutter-root=
$flutterRoot
'
,
'-Poutput-dir=
${outputDirectory.path}
'
,
'-Poutput-dir=
${outputDirectory.path}
'
,
'-Pis-plugin=
${manifest.isPlugin}
'
,
'-Pis-plugin=
${manifest.isPlugin}
'
,
'-PbuildNumber=
$buildNumber
'
];
];
if
(
target
!=
null
&&
target
.
isNotEmpty
)
{
if
(
target
!=
null
&&
target
.
isNotEmpty
)
{
...
@@ -587,10 +591,12 @@ void printHowToConsumeAar({
...
@@ -587,10 +591,12 @@ void printHowToConsumeAar({
@required
Set
<
String
>
buildModes
,
@required
Set
<
String
>
buildModes
,
@required
String
androidPackage
,
@required
String
androidPackage
,
@required
Directory
repoDirectory
,
@required
Directory
repoDirectory
,
String
buildNumber
,
})
{
})
{
assert
(
buildModes
!=
null
&&
buildModes
.
isNotEmpty
);
assert
(
buildModes
!=
null
&&
buildModes
.
isNotEmpty
);
assert
(
androidPackage
!=
null
);
assert
(
androidPackage
!=
null
);
assert
(
repoDirectory
!=
null
);
assert
(
repoDirectory
!=
null
);
buildNumber
??=
'1.0'
;
printStatus
(
'''
printStatus
(
'''
...
@@ -613,7 +619,7 @@ ${terminal.bolden('Consuming the Module')}
...
@@ -613,7 +619,7 @@ ${terminal.bolden('Consuming the Module')}
for (String buildMode in buildModes) {
for (String buildMode in buildModes) {
printStatus('''
printStatus('''
$
{
buildMode
}
Implementation
'
$androidPackage
:flutter_
$buildMode
:
1.0
'''
);
$
{
buildMode
}
Implementation
'
$androidPackage
:flutter_
$buildMode
:
$buildNumber
'''
);
}
}
printStatus
(
'''
printStatus
(
'''
...
@@ -721,6 +727,7 @@ Future<void> buildPluginsAsAar(
...
@@ -721,6 +727,7 @@ Future<void> buildPluginsAsAar(
),
),
target:
''
,
target:
''
,
outputDirectory:
buildDirectory
,
outputDirectory:
buildDirectory
,
buildNumber:
'1.0'
);
);
}
on
ToolExit
{
}
on
ToolExit
{
// Log the entire plugin entry in `.flutter-plugins` since it
// Log the entire plugin entry in `.flutter-plugins` since it
...
...
packages/flutter_tools/lib/src/commands/build_aar.dart
View file @
418b8145
...
@@ -33,6 +33,7 @@ class BuildAarCommand extends BuildSubCommand {
...
@@ -33,6 +33,7 @@ class BuildAarCommand extends BuildSubCommand {
help:
'Build a release version of the current project.'
,
help:
'Build a release version of the current project.'
,
);
);
usesFlavorOption
();
usesFlavorOption
();
usesBuildNumberOption
();
usesPubOption
();
usesPubOption
();
argParser
argParser
..
addMultiOption
(
..
addMultiOption
(
...
@@ -85,17 +86,22 @@ class BuildAarCommand extends BuildSubCommand {
...
@@ -85,17 +86,22 @@ class BuildAarCommand extends BuildSubCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
final
Set
<
AndroidBuildInfo
>
androidBuildInfo
=
<
AndroidBuildInfo
>{};
final
Set
<
AndroidBuildInfo
>
androidBuildInfo
=
<
AndroidBuildInfo
>{};
final
Iterable
<
AndroidArch
>
targetArchitectures
=
stringsArg
(
'target-platform'
)
.
map
<
AndroidArch
>(
getAndroidArchForName
);
final
Iterable
<
AndroidArch
>
targetArchitectures
=
stringsArg
(
'target-platform'
).
map
<
AndroidArch
>(
getAndroidArchForName
);
final
String
buildNumber
=
argParser
.
options
.
containsKey
(
'build-number'
)
&&
stringArg
(
'build-number'
)
!=
null
&&
stringArg
(
'build-number'
).
isNotEmpty
?
stringArg
(
'build-number'
)
:
'1.0'
;
for
(
String
buildMode
in
const
<
String
>[
'debug'
,
'profile'
,
'release'
])
{
for
(
String
buildMode
in
const
<
String
>[
'debug'
,
'profile'
,
'release'
])
{
if
(
boolArg
(
buildMode
))
{
if
(
boolArg
(
buildMode
))
{
androidBuildInfo
.
add
(
androidBuildInfo
.
add
(
AndroidBuildInfo
(
AndroidBuildInfo
(
BuildInfo
(
BuildMode
.
fromName
(
buildMode
),
stringArg
(
'flavor'
)),
BuildInfo
(
BuildMode
.
fromName
(
buildMode
),
stringArg
(
'flavor'
)),
targetArchs:
targetArchitectures
,
targetArchs:
targetArchitectures
,
));
)
);
}
}
}
}
if
(
androidBuildInfo
.
isEmpty
)
{
if
(
androidBuildInfo
.
isEmpty
)
{
...
@@ -106,6 +112,7 @@ class BuildAarCommand extends BuildSubCommand {
...
@@ -106,6 +112,7 @@ class BuildAarCommand extends BuildSubCommand {
target:
''
,
// Not needed because this command only builds Android's code.
target:
''
,
// Not needed because this command only builds Android's code.
androidBuildInfo:
androidBuildInfo
,
androidBuildInfo:
androidBuildInfo
,
outputDirectoryPath:
stringArg
(
'output-dir'
),
outputDirectoryPath:
stringArg
(
'output-dir'
),
buildNumber:
buildNumber
,
);
);
return
null
;
return
null
;
}
}
...
...
packages/flutter_tools/test/general.shard/android/gradle_test.dart
View file @
418b8145
...
@@ -936,6 +936,7 @@ plugin2=${plugin2.path}
...
@@ -936,6 +936,7 @@ plugin2=${plugin2.path}
'-Pflutter-root=
$flutterRoot
'
,
'-Pflutter-root=
$flutterRoot
'
,
'-Poutput-dir=
${buildDirectory.path}
'
,
'-Poutput-dir=
${buildDirectory.path}
'
,
'-Pis-plugin=true'
,
'-Pis-plugin=true'
,
'-PbuildNumber=1.0'
,
'-Ptarget-platform=android-arm,android-arm64,android-x64'
,
'-Ptarget-platform=android-arm,android-arm64,android-x64'
,
'assembleAarRelease'
,
'assembleAarRelease'
,
],
],
...
@@ -950,6 +951,7 @@ plugin2=${plugin2.path}
...
@@ -950,6 +951,7 @@ plugin2=${plugin2.path}
'-Pflutter-root=
$flutterRoot
'
,
'-Pflutter-root=
$flutterRoot
'
,
'-Poutput-dir=
${buildDirectory.path}
'
,
'-Poutput-dir=
${buildDirectory.path}
'
,
'-Pis-plugin=true'
,
'-Pis-plugin=true'
,
'-PbuildNumber=1.0'
,
'-Ptarget-platform=android-arm,android-arm64,android-x64'
,
'-Ptarget-platform=android-arm,android-arm64,android-x64'
,
'assembleAarRelease'
,
'assembleAarRelease'
,
],
],
...
@@ -1548,6 +1550,7 @@ plugin2=${plugin2.path}
...
@@ -1548,6 +1550,7 @@ plugin2=${plugin2.path}
project:
FlutterProject
.
current
(),
project:
FlutterProject
.
current
(),
outputDirectory:
fs
.
directory
(
'build/'
),
outputDirectory:
fs
.
directory
(
'build/'
),
target:
''
,
target:
''
,
buildNumber:
'1.0'
,
);
);
expect
(
expect
(
...
@@ -1710,6 +1713,7 @@ plugin2=${plugin2.path}
...
@@ -1710,6 +1713,7 @@ plugin2=${plugin2.path}
project:
FlutterProject
.
current
(),
project:
FlutterProject
.
current
(),
outputDirectory:
fs
.
directory
(
'build/'
),
outputDirectory:
fs
.
directory
(
'build/'
),
target:
''
,
target:
''
,
buildNumber:
'2.0'
,
);
);
final
List
<
String
>
actualGradlewCall
=
verify
(
final
List
<
String
>
actualGradlewCall
=
verify
(
...
@@ -1724,6 +1728,7 @@ plugin2=${plugin2.path}
...
@@ -1724,6 +1728,7 @@ plugin2=${plugin2.path}
expect
(
actualGradlewCall
,
contains
(
'-Plocal-engine-out=out/android_arm'
));
expect
(
actualGradlewCall
,
contains
(
'-Plocal-engine-out=out/android_arm'
));
expect
(
actualGradlewCall
,
contains
(
'-Plocal-engine-repo=/.tmp_rand0/flutter_tool_local_engine_repo.rand0'
));
expect
(
actualGradlewCall
,
contains
(
'-Plocal-engine-repo=/.tmp_rand0/flutter_tool_local_engine_repo.rand0'
));
expect
(
actualGradlewCall
,
contains
(
'-Plocal-engine-build-mode=release'
));
expect
(
actualGradlewCall
,
contains
(
'-Plocal-engine-build-mode=release'
));
expect
(
actualGradlewCall
,
contains
(
'-PbuildNumber=2.0'
));
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
AndroidSdk:
()
=>
mockAndroidSdk
,
...
@@ -1742,6 +1747,7 @@ plugin2=${plugin2.path}
...
@@ -1742,6 +1747,7 @@ plugin2=${plugin2.path}
buildModes:
const
<
String
>{
'release'
,
'debug'
,
'profile'
},
buildModes:
const
<
String
>{
'release'
,
'debug'
,
'profile'
},
androidPackage:
'com.mycompany'
,
androidPackage:
'com.mycompany'
,
repoDirectory:
fs
.
directory
(
'build/'
),
repoDirectory:
fs
.
directory
(
'build/'
),
buildNumber:
'2.2'
,
);
);
expect
(
expect
(
...
@@ -1764,9 +1770,9 @@ plugin2=${plugin2.path}
...
@@ -1764,9 +1770,9 @@ plugin2=${plugin2.path}
' 3. Make the host app depend on the Flutter module:
\n
'
' 3. Make the host app depend on the Flutter module:
\n
'
'
\n
'
'
\n
'
' dependencies {
\n
'
' dependencies {
\n
'
' releaseImplementation
\'
com.mycompany:flutter_release:
1.0
\n
'
' releaseImplementation
\'
com.mycompany:flutter_release:
2.2
\n
'
' debugImplementation
\'
com.mycompany:flutter_debug:
1.0
\n
'
' debugImplementation
\'
com.mycompany:flutter_debug:
2.2
\n
'
' profileImplementation
\'
com.mycompany:flutter_profile:
1.0
\n
'
' profileImplementation
\'
com.mycompany:flutter_profile:
2.2
\n
'
' }
\n
'
' }
\n
'
'
\n
'
'
\n
'
'
\n
'
'
\n
'
...
@@ -1872,6 +1878,7 @@ plugin2=${plugin2.path}
...
@@ -1872,6 +1878,7 @@ plugin2=${plugin2.path}
buildModes:
const
<
String
>{
'profile'
},
buildModes:
const
<
String
>{
'profile'
},
androidPackage:
'com.mycompany'
,
androidPackage:
'com.mycompany'
,
repoDirectory:
fs
.
directory
(
'build/'
),
repoDirectory:
fs
.
directory
(
'build/'
),
buildNumber:
'1.0'
,
);
);
expect
(
expect
(
...
...
packages/flutter_tools/test/src/android_common.dart
View file @
418b8145
...
@@ -16,6 +16,7 @@ class FakeAndroidBuilder implements AndroidBuilder {
...
@@ -16,6 +16,7 @@ class FakeAndroidBuilder implements AndroidBuilder {
@required
Set
<
AndroidBuildInfo
>
androidBuildInfo
,
@required
Set
<
AndroidBuildInfo
>
androidBuildInfo
,
@required
String
target
,
@required
String
target
,
@required
String
outputDirectoryPath
,
@required
String
outputDirectoryPath
,
@required
String
buildNumber
,
})
async
{}
})
async
{}
@override
@override
...
...
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