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
8e30cc9c
Unverified
Commit
8e30cc9c
authored
Oct 04, 2022
by
林军华
Committed by
GitHub
Oct 04, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert file naming convention of .aar files to support fuzzy matching in build.gradle (#112149)
parent
35afe1bd
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
252 deletions
+41
-252
AUTHORS
AUTHORS
+1
-0
android_obfuscate_test.dart
dev/devicelab/bin/tasks/android_obfuscate_test.dart
+8
-41
build_aar_module_test.dart
dev/devicelab/bin/tasks/build_aar_module_test.dart
+10
-163
aar_init_script.gradle
packages/flutter_tools/gradle/aar_init_script.gradle
+15
-41
gradle.dart
packages/flutter_tools/lib/src/android/gradle.dart
+1
-1
gradle_test.dart
...flutter_tools/test/general.shard/android/gradle_test.dart
+6
-6
No files found.
AUTHORS
View file @
8e30cc9c
...
@@ -96,3 +96,4 @@ Jonathan Joelson <jon@joelson.co>
...
@@ -96,3 +96,4 @@ Jonathan Joelson <jon@joelson.co>
Elsabe Ros <hello@elsabe.dev>
Elsabe Ros <hello@elsabe.dev>
Nguyễn Phúc Lợi <nploi1998@gmail.com>
Nguyễn Phúc Lợi <nploi1998@gmail.com>
Jingyi Chen <jingyichen@link.cuhk.edu.cn>
Jingyi Chen <jingyichen@link.cuhk.edu.cn>
Junhua Lin <1075209054@qq.com>
dev/devicelab/bin/tasks/android_obfuscate_test.dart
View file @
8e30cc9c
...
@@ -51,8 +51,7 @@ Future<void> main() async {
...
@@ -51,8 +51,7 @@ Future<void> main() async {
});
});
});
});
bool
foundProjectNameInOldAar
=
false
;
bool
foundAarProjectName
=
false
;
bool
foundProjectNameInNewAar
=
false
;
await
runModuleProjectTest
((
FlutterModuleProject
flutterProject
)
async
{
await
runModuleProjectTest
((
FlutterModuleProject
flutterProject
)
async
{
section
(
'AAR content with --obfuscate'
);
section
(
'AAR content with --obfuscate'
);
...
@@ -68,49 +67,21 @@ Future<void> main() async {
...
@@ -68,49 +67,21 @@ Future<void> main() async {
]);
]);
});
});
section
(
'Check old _release AAR files'
);
final
String
outputAarDirectory
=
path
.
join
(
final
String
oldReleaseAar
=
path
.
join
(
flutterProject
.
rootPath
,
flutterProject
.
rootPath
,
'build/host/outputs/repo/com/example/
${flutterProject.name}
/flutter_release/1.0/flutter_release-1.0.aar'
,
'build/host/outputs/repo/com/example/
${flutterProject.name}
/flutter_release/1.0/flutter_release-1.0.aar'
,
);
);
final
Iterable
<
String
>
filesInOldAar
=
await
getFilesInAar
(
oldReleaseAar
);
final
Iterable
<
String
>
aarFiles
=
await
getFilesInAar
(
outputAarDirectory
);
checkCollectionContains
<
String
>(<
String
>[
checkCollectionContains
<
String
>(<
String
>[
...
flutterAssets
,
...
flutterAssets
,
'jni/armeabi-v7a/libapp.so'
,
'jni/armeabi-v7a/libapp.so'
,
],
filesInOldAar
);
],
aarFiles
);
// Verify that an identifier from the Dart project code is not present
// Verify that an identifier from the Dart project code is not present
// in the compiled binary.
// in the compiled binary.
await
inDirectory
(
flutterProject
.
rootPath
,
()
async
{
await
inDirectory
(
flutterProject
.
rootPath
,
()
async
{
await
exec
(
'unzip'
,
<
String
>[
'-o'
,
oldReleaseAar
]);
await
exec
(
'unzip'
,
<
String
>[
outputAarDirectory
]);
checkFileExists
(
path
.
join
(
flutterProject
.
rootPath
,
'jni/armeabi-v7a/libapp.so'
));
final
String
response
=
await
eval
(
'grep'
,
<
String
>[
flutterProject
.
name
,
'jni/armeabi-v7a/libapp.so'
],
canFail:
true
,
);
if
(
response
.
trim
().
contains
(
'matches'
))
{
foundProjectNameInOldAar
=
true
;
}
});
section
(
'Check new -release AAR files'
);
final
String
newReleaseAar
=
path
.
join
(
flutterProject
.
rootPath
,
'build/host/outputs/repo/com/example/
${flutterProject.name}
/flutter/1.0/flutter-1.0-release.aar'
,
);
final
Iterable
<
String
>
filesInNewAar
=
await
getFilesInAar
(
newReleaseAar
);
checkCollectionContains
<
String
>(<
String
>[
...
flutterAssets
,
'jni/armeabi-v7a/libapp.so'
,
],
filesInNewAar
);
await
inDirectory
(
flutterProject
.
rootPath
,
()
async
{
await
exec
(
'unzip'
,
<
String
>[
'-o'
,
newReleaseAar
]);
checkFileExists
(
path
.
join
(
flutterProject
.
rootPath
,
'jni/armeabi-v7a/libapp.so'
));
checkFileExists
(
path
.
join
(
flutterProject
.
rootPath
,
'jni/armeabi-v7a/libapp.so'
));
final
String
response
=
await
eval
(
final
String
response
=
await
eval
(
'grep'
,
'grep'
,
...
@@ -118,20 +89,16 @@ Future<void> main() async {
...
@@ -118,20 +89,16 @@ Future<void> main() async {
canFail:
true
,
canFail:
true
,
);
);
if
(
response
.
trim
().
contains
(
'matches'
))
{
if
(
response
.
trim
().
contains
(
'matches'
))
{
found
ProjectNameInNewAar
=
true
;
found
AarProjectName
=
true
;
}
}
});
});
});
});
if
(
foundApkProjectName
)
{
if
(
foundApkProjectName
)
{
return
TaskResult
.
failure
(
'Found project name in obfuscated APK dart library'
);
return
TaskResult
.
failure
(
'Found project name in obfuscated APK dart library'
);
}
}
if
(
foundProjectNameInOldAar
)
{
if
(
foundAarProjectName
)
{
return
TaskResult
.
failure
(
'Found project name in obfuscated AAR _release dart library'
);
return
TaskResult
.
failure
(
'Found project name in obfuscated AAR dart library'
);
}
if
(
foundProjectNameInNewAar
)
{
return
TaskResult
.
failure
(
'Found project name in obfuscated AAR -release dart library'
);
}
}
return
TaskResult
.
success
(
null
);
return
TaskResult
.
success
(
null
);
...
...
dev/devicelab/bin/tasks/build_aar_module_test.dart
View file @
8e30cc9c
...
@@ -95,7 +95,7 @@ Future<void> main() async {
...
@@ -95,7 +95,7 @@ Future<void> main() async {
'repo'
,
'repo'
,
);
);
section
(
'Check release Maven artifacts
(old format)
'
);
section
(
'Check release Maven artifacts'
);
checkFileExists
(
path
.
join
(
checkFileExists
(
path
.
join
(
repoPath
,
repoPath
,
...
@@ -108,7 +108,7 @@ Future<void> main() async {
...
@@ -108,7 +108,7 @@ Future<void> main() async {
'flutter_release-1.0.aar'
,
'flutter_release-1.0.aar'
,
));
));
final
String
releasePom
Old
=
path
.
join
(
final
String
releasePom
=
path
.
join
(
repoPath
,
repoPath
,
'io'
,
'io'
,
'flutter'
,
'flutter'
,
...
@@ -119,7 +119,7 @@ Future<void> main() async {
...
@@ -119,7 +119,7 @@ Future<void> main() async {
'flutter_release-1.0.pom'
,
'flutter_release-1.0.pom'
,
);
);
checkFileExists
(
releasePom
Old
);
checkFileExists
(
releasePom
);
checkFileExists
(
path
.
join
(
checkFileExists
(
path
.
join
(
repoPath
,
repoPath
,
...
@@ -143,54 +143,6 @@ Future<void> main() async {
...
@@ -143,54 +143,6 @@ Future<void> main() async {
'plugin_with_android_release-1.0.pom'
,
'plugin_with_android_release-1.0.pom'
,
));
));
section
(
'Check release Maven artifacts (new format)'
);
checkFileExists
(
path
.
join
(
repoPath
,
'io'
,
'flutter'
,
'devicelab'
,
'hello'
,
'flutter'
,
'1.0'
,
'flutter-1.0-release.aar'
,
));
final
String
releasePomNew
=
path
.
join
(
repoPath
,
'io'
,
'flutter'
,
'devicelab'
,
'hello'
,
'flutter'
,
'1.0'
,
'flutter-1.0.pom'
,
);
checkFileExists
(
releasePomNew
);
checkFileExists
(
path
.
join
(
repoPath
,
'io'
,
'flutter'
,
'devicelab'
,
'plugin_with_android'
,
'plugin_with_android'
,
'1.0'
,
'plugin_with_android-1.0-release.aar'
,
));
checkFileExists
(
path
.
join
(
repoPath
,
'io'
,
'flutter'
,
'devicelab'
,
'plugin_with_android'
,
'plugin_with_android'
,
'1.0'
,
'plugin_with_android-1.0.pom'
,
));
section
(
'Check AOT blobs in release POM'
);
section
(
'Check AOT blobs in release POM'
);
checkFileContains
(<
String
>[
checkFileContains
(<
String
>[
...
@@ -198,17 +150,8 @@ Future<void> main() async {
...
@@ -198,17 +150,8 @@ Future<void> main() async {
'armeabi_v7a_release'
,
'armeabi_v7a_release'
,
'arm64_v8a_release'
,
'arm64_v8a_release'
,
'x86_64_release'
,
'x86_64_release'
,
'plugin_with_android'
,
'plugin_with_android_release'
,
'<relocation>'
,
//make sure the old pom contains the <relocation> tag
],
releasePom
);
],
releasePomOld
);
checkFileContains
(<
String
>[
'flutter_embedding_release'
,
'armeabi_v7a_release'
,
'arm64_v8a_release'
,
'x86_64_release'
,
'plugin_with_android'
,
],
releasePomNew
);
section
(
'Check assets in release AAR'
);
section
(
'Check assets in release AAR'
);
...
@@ -234,29 +177,7 @@ Future<void> main() async {
...
@@ -234,29 +177,7 @@ Future<void> main() async {
)
)
);
);
checkCollectionContains
<
String
>(
section
(
'Check debug Maven artifacts'
);
<
String
>[
...
flutterAssets
,
// AOT snapshots
'jni/arm64-v8a/libapp.so'
,
'jni/armeabi-v7a/libapp.so'
,
'jni/x86_64/libapp.so'
,
],
await
getFilesInAar
(
path
.
join
(
repoPath
,
'io'
,
'flutter'
,
'devicelab'
,
'hello'
,
'flutter'
,
'1.0'
,
'flutter-1.0-release.aar'
,
)
)
);
section
(
'Check debug Maven artifacts (old format)'
);
checkFileExists
(
path
.
join
(
checkFileExists
(
path
.
join
(
repoPath
,
repoPath
,
...
@@ -269,7 +190,7 @@ Future<void> main() async {
...
@@ -269,7 +190,7 @@ Future<void> main() async {
'flutter_debug-1.0.aar'
,
'flutter_debug-1.0.aar'
,
));
));
final
String
debugPom
Old
=
path
.
join
(
final
String
debugPom
=
path
.
join
(
repoPath
,
repoPath
,
'io'
,
'io'
,
'flutter'
,
'flutter'
,
...
@@ -280,7 +201,7 @@ Future<void> main() async {
...
@@ -280,7 +201,7 @@ Future<void> main() async {
'flutter_debug-1.0.pom'
,
'flutter_debug-1.0.pom'
,
);
);
checkFileExists
(
debugPom
Old
);
checkFileExists
(
debugPom
);
checkFileExists
(
path
.
join
(
checkFileExists
(
path
.
join
(
repoPath
,
repoPath
,
...
@@ -304,54 +225,6 @@ Future<void> main() async {
...
@@ -304,54 +225,6 @@ Future<void> main() async {
'plugin_with_android_debug-1.0.pom'
,
'plugin_with_android_debug-1.0.pom'
,
));
));
section
(
'Check debug Maven artifacts (new format)'
);
checkFileExists
(
path
.
join
(
repoPath
,
'io'
,
'flutter'
,
'devicelab'
,
'hello'
,
'flutter'
,
'1.0'
,
'flutter-1.0-debug.aar'
,
));
final
String
debugPomNew
=
path
.
join
(
repoPath
,
'io'
,
'flutter'
,
'devicelab'
,
'hello'
,
'flutter'
,
'1.0'
,
'flutter-1.0.pom'
,
);
checkFileExists
(
debugPomNew
);
checkFileExists
(
path
.
join
(
repoPath
,
'io'
,
'flutter'
,
'devicelab'
,
'plugin_with_android'
,
'plugin_with_android'
,
'1.0'
,
'plugin_with_android-1.0-debug.aar'
,
));
checkFileExists
(
path
.
join
(
repoPath
,
'io'
,
'flutter'
,
'devicelab'
,
'plugin_with_android'
,
'plugin_with_android'
,
'1.0'
,
'plugin_with_android-1.0.pom'
,
));
section
(
'Check AOT blobs in debug POM'
);
section
(
'Check AOT blobs in debug POM'
);
checkFileContains
(<
String
>[
checkFileContains
(<
String
>[
...
@@ -360,18 +233,8 @@ Future<void> main() async {
...
@@ -360,18 +233,8 @@ Future<void> main() async {
'x86_64_debug'
,
'x86_64_debug'
,
'armeabi_v7a_debug'
,
'armeabi_v7a_debug'
,
'arm64_v8a_debug'
,
'arm64_v8a_debug'
,
'plugin_with_android'
,
'plugin_with_android_debug'
,
'<relocation>'
,
//make sure the old pom contains the <relocation> tag
],
debugPom
);
],
debugPomOld
);
checkFileContains
(<
String
>[
'flutter_embedding_debug'
,
'x86_debug'
,
'x86_64_debug'
,
'armeabi_v7a_debug'
,
'arm64_v8a_debug'
,
'plugin_with_android'
,
],
debugPomNew
);
section
(
'Check assets in debug AAR'
);
section
(
'Check assets in debug AAR'
);
...
@@ -386,27 +249,11 @@ Future<void> main() async {
...
@@ -386,27 +249,11 @@ Future<void> main() async {
'flutter_debug-1.0.aar'
,
'flutter_debug-1.0.aar'
,
));
));
final
Iterable
<
String
>
debugAarNew
=
await
getFilesInAar
(
path
.
join
(
repoPath
,
'io'
,
'flutter'
,
'devicelab'
,
'hello'
,
'flutter'
,
'1.0'
,
'flutter-1.0-debug.aar'
,
));
checkCollectionContains
<
String
>(<
String
>[
checkCollectionContains
<
String
>(<
String
>[
...
flutterAssets
,
...
flutterAssets
,
...
debugAssets
,
...
debugAssets
,
],
debugAar
);
],
debugAar
);
checkCollectionContains
<
String
>(<
String
>[
...
flutterAssets
,
...
debugAssets
,
],
debugAarNew
);
return
TaskResult
.
success
(
null
);
return
TaskResult
.
success
(
null
);
}
on
TaskResult
catch
(
taskResult
)
{
}
on
TaskResult
catch
(
taskResult
)
{
return
taskResult
;
return
taskResult
;
...
...
packages/flutter_tools/gradle/aar_init_script.gradle
View file @
8e30cc9c
...
@@ -26,8 +26,10 @@ void configureProject(Project project, String outputDir) {
...
@@ -26,8 +26,10 @@ void configureProject(Project project, String outputDir) {
project
.
version
=
project
.
property
(
"buildNumber"
)
project
.
version
=
project
.
property
(
"buildNumber"
)
}
}
project
.
android
.
libraryVariants
.
all
{
variant
->
project
.
components
.
forEach
{
component
->
addAarTask
(
project
,
variant
)
if
(
component
.
name
!=
"all"
)
{
addAarTask
(
project
,
component
)
}
}
}
project
.
publishing
{
project
.
publishing
{
...
@@ -38,43 +40,6 @@ void configureProject(Project project, String outputDir) {
...
@@ -38,43 +40,6 @@ void configureProject(Project project, String outputDir) {
}
}
}
}
// Some extra work to have alternative publications with the same format as the old maven plugin.
// Instead of using classifiers for the variants, the old maven plugin appended `_{variant}` to the artifactId
// First, create a default MavenPublication for each variant (except "all" since that is used to publish artifacts in the new way)
project
.
components
.
forEach
{
component
->
if
(
component
.
name
!=
"all"
)
{
project
.
publishing
.
publications
.
create
(
component
.
name
,
MavenPublication
)
{
from
component
}
}
}
// then, rename the artifactId to include the variant and make sure to remove any classifier
// data tha gradle has set, as well as adding a <relocation> tag pointing to the new coordinates
project
.
publishing
.
publications
.
forEach
{
pub
->
def
relocationArtifactId
=
pub
.
artifactId
pub
.
artifactId
=
"${relocationArtifactId}_${pub.name}"
pub
.
alias
=
true
pub
.
pom
.
distributionManagement
{
relocation
{
// New artifact coordinates
groupId
=
"${pub.groupId}"
artifactId
=
"${relocationArtifactId}"
version
=
"${pub.version}"
message
=
"Use classifiers rather than _variant for new publish plugin"
}
}
}
// also publish the artifacts in the new way, using one set of coordinates with classifiers
project
.
publishing
.
publications
.
create
(
"all"
,
MavenPublication
)
{
from
project
.
components
.
all
alias
false
}
if
(!
project
.
property
(
"is-plugin"
).
toBoolean
())
{
if
(!
project
.
property
(
"is-plugin"
).
toBoolean
())
{
return
return
}
}
...
@@ -114,14 +79,23 @@ String getFlutterRoot(Project project) {
...
@@ -114,14 +79,23 @@ String getFlutterRoot(Project project) {
return
project
.
property
(
"flutter-root"
)
return
project
.
property
(
"flutter-root"
)
}
}
void
addAarTask
(
Project
project
,
varia
nt
)
{
void
addAarTask
(
Project
project
,
compone
nt
)
{
String
variantName
=
varia
nt
.
name
.
capitalize
()
String
variantName
=
compone
nt
.
name
.
capitalize
()
String
taskName
=
"assembleAar$variantName"
String
taskName
=
"assembleAar$variantName"
project
.
tasks
.
create
(
name:
taskName
)
{
project
.
tasks
.
create
(
name:
taskName
)
{
// This check is required to be able to configure the archives before `publish` runs.
// This check is required to be able to configure the archives before `publish` runs.
if
(!
project
.
gradle
.
startParameter
.
taskNames
.
contains
(
taskName
))
{
if
(!
project
.
gradle
.
startParameter
.
taskNames
.
contains
(
taskName
))
{
return
return
}
}
// Create a default MavenPublication for the variant (except "all" since that is used to publish artifacts in the new way)
project
.
publishing
.
publications
.
create
(
component
.
name
,
MavenPublication
)
{
pub
->
groupId
=
"${pub.groupId}"
artifactId
=
"${pub.artifactId}_${pub.name}"
version
=
"${pub.version}"
from
component
}
// Generate the Maven artifacts.
// Generate the Maven artifacts.
finalizedBy
"publish"
finalizedBy
"publish"
}
}
...
...
packages/flutter_tools/lib/src/android/gradle.dart
View file @
8e30cc9c
...
@@ -726,7 +726,7 @@ void printHowToConsumeAar({
...
@@ -726,7 +726,7 @@ void printHowToConsumeAar({
for
(
final
String
buildMode
in
buildModes
)
{
for
(
final
String
buildMode
in
buildModes
)
{
logger
.
printStatus
(
"""
logger
.
printStatus
(
"""
${buildMode}
Implementation '
$androidPackage
:flutter
:
$buildNumber
:
$buildMode
'"""
);
${buildMode}
Implementation '
$androidPackage
:flutter
_
$buildMode
:
$buildNumber
'"""
);
}
}
logger
.
printStatus
(
'''
logger
.
printStatus
(
'''
...
...
packages/flutter_tools/test/general.shard/android/gradle_test.dart
View file @
8e30cc9c
...
@@ -540,9 +540,9 @@ flutter:
...
@@ -540,9 +540,9 @@ flutter:
' 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
:2.2:release
'
\n
"
" releaseImplementation 'com.mycompany:flutter
_release:2.2
'
\n
"
" debugImplementation 'com.mycompany:flutter
:2.2:debug
'
\n
"
" debugImplementation 'com.mycompany:flutter
_debug:2.2
'
\n
"
" profileImplementation 'com.mycompany:flutter
:2.2:profile
'
\n
"
" profileImplementation 'com.mycompany:flutter
_profile:2.2
'
\n
"
' }
\n
'
' }
\n
'
'
\n
'
'
\n
'
'
\n
'
'
\n
'
...
@@ -591,7 +591,7 @@ flutter:
...
@@ -591,7 +591,7 @@ flutter:
' 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
:1.0:release
'
\n
"
" releaseImplementation 'com.mycompany:flutter
_release:1.0
'
\n
"
' }
\n
'
' }
\n
'
'
\n
'
'
\n
'
'To learn more, visit https://flutter.dev/go/build-aar
\n
'
'To learn more, visit https://flutter.dev/go/build-aar
\n
'
...
@@ -629,7 +629,7 @@ flutter:
...
@@ -629,7 +629,7 @@ flutter:
' 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
'
" debugImplementation 'com.mycompany:flutter
:1.0:debug
'
\n
"
" debugImplementation 'com.mycompany:flutter
_debug:1.0
'
\n
"
' }
\n
'
' }
\n
'
'
\n
'
'
\n
'
'To learn more, visit https://flutter.dev/go/build-aar
\n
'
'To learn more, visit https://flutter.dev/go/build-aar
\n
'
...
@@ -668,7 +668,7 @@ flutter:
...
@@ -668,7 +668,7 @@ flutter:
' 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
'
" profileImplementation 'com.mycompany:flutter
:1.0:profile
'
\n
"
" profileImplementation 'com.mycompany:flutter
_profile:1.0
'
\n
"
' }
\n
'
' }
\n
'
'
\n
'
'
\n
'
'
\n
'
'
\n
'
...
...
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