fix fialing lint Consider using 'register' to avoid unnecessary configuration (#159137)

fix failing lint `Consider using 'register' to avoid unnecessary
configuration` in Android studio :
![Capture d’écran 2024-11-19
132110](https://github.com/user-attachments/assets/ffc98203-5563-4846-aa42-60a0b8defa27)

![Capture d’écran 2024-11-19
133050](https://github.com/user-attachments/assets/7671b6f4-5a18-460a-8456-608a40e6da22)
see #147122
## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
Mohellebi abdessalem 2024-12-03 22:15:25 +01:00 committed by GitHub
parent 980df92204
commit 1b048b0219
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,6 +26,7 @@ import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.OutputFiles
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.bundling.Jar
import org.gradle.internal.os.OperatingSystem
@ -1248,7 +1249,7 @@ class FlutterPlugin implements Plugin<Project> {
// original value. You either need to hoist the value
// into a separate variable `verbose verboseValue` or prefix with
// `this` (`verbose this.isVerbose()`).
FlutterTask compileTask = project.tasks.create(name: taskName, type: FlutterTask) {
TaskProvider<FlutterTask> compileTaskProvider = project.tasks.register(taskName , FlutterTask) {
flutterRoot(this.flutterRoot)
flutterExecutable(this.flutterExecutable)
buildMode(variantBuildMode)
@ -1279,8 +1280,9 @@ class FlutterPlugin implements Plugin<Project> {
validateDeferredComponents(validateDeferredComponentsValue)
flavor(flavorValue)
}
Task compileTask = compileTaskProvider.get();
File libJar = project.file(project.layout.buildDirectory.dir("$INTERMEDIATES_DIR/flutter/${variant.name}/libs.jar"))
Task packJniLibsTask = project.tasks.create(name: "packJniLibs${FLUTTER_BUILD_PREFIX}${variant.name.capitalize()}", type: Jar) {
TaskProvider<Jar> packJniLibsTaskProvider = project.tasks.register("packJniLibs${FLUTTER_BUILD_PREFIX}${variant.name.capitalize()}", Jar) {
destinationDirectory = libJar.parentFile
archiveFileName = libJar.name
dependsOn compileTask
@ -1305,12 +1307,12 @@ class FlutterPlugin implements Plugin<Project> {
}
}
}
Task packJniLibsTask = packJniLibsTaskProvider.get();
addApiDependencies(project, variant.name, project.files {
packJniLibsTask
})
Task copyFlutterAssetsTask = project.tasks.create(
name: "copyFlutterAssets${variant.name.capitalize()}",
type: Copy,
TaskProvider<Copy> copyFlutterAssetsTaskProvider = project.tasks.register(
"copyFlutterAssets${variant.name.capitalize()}" , Copy
) {
dependsOn(compileTask)
with(compileTask.assets)
@ -1344,6 +1346,7 @@ class FlutterPlugin implements Plugin<Project> {
mergeAssets.mustRunAfter("clean${mergeAssets.name.capitalize()}")
into(mergeAssets.outputDir)
}
Task copyFlutterAssetsTask = copyFlutterAssetsTaskProvider.get();
if (!isUsedAsSubproject) {
def variantOutput = variant.outputs.first()
def processResources = variantOutput.hasProperty(propProcessResourcesProvider) ?