Refactor code inside flutter.groovy (#160250)
remove unnecessary spacing remove the usage of System.env because it is dynamic . the getProperty have the ability to take a second argument wich will be the default value android studio linter is prompting `Consider using 'configureEach' to avoid unnecessary configuration` android studio linter is prompting `Call to 'get' can be keyed access ` android studio linter is prompting `Cannot determine type of 'o'` ## 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]. - [x] All existing and new tests are passing. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] 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]. 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:
parent
b5c3a9fa61
commit
29bb5e7a00
@ -48,7 +48,7 @@ class FlutterExtension {
|
|||||||
public final int compileSdkVersion = 35
|
public final int compileSdkVersion = 35
|
||||||
|
|
||||||
/** Sets the minSdkVersion used by default in Flutter app projects. */
|
/** Sets the minSdkVersion used by default in Flutter app projects. */
|
||||||
public final int minSdkVersion = 21
|
public final int minSdkVersion = 21
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the targetSdkVersion used by default in Flutter app projects.
|
* Sets the targetSdkVersion used by default in Flutter app projects.
|
||||||
@ -196,7 +196,7 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String flutterRootPath = resolveProperty("flutter.sdk", System.env.FLUTTER_ROOT)
|
String flutterRootPath = resolveProperty("flutter.sdk", System.getenv("FLUTTER_ROOT"))
|
||||||
if (flutterRootPath == null) {
|
if (flutterRootPath == null) {
|
||||||
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file or with a FLUTTER_ROOT environment variable.")
|
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file or with a FLUTTER_ROOT environment variable.")
|
||||||
}
|
}
|
||||||
@ -211,11 +211,11 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
|
|
||||||
engineRealm = Paths.get(flutterRoot.absolutePath, "bin", "internal", "engine.realm").toFile().text.trim()
|
engineRealm = Paths.get(flutterRoot.absolutePath, "bin", "internal", "engine.realm").toFile().text.trim()
|
||||||
if (engineRealm) {
|
if (engineRealm) {
|
||||||
engineRealm = engineRealm + "/"
|
engineRealm += "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure the Maven repository.
|
// Configure the Maven repository.
|
||||||
String hostedRepository = System.env.FLUTTER_STORAGE_BASE_URL ?: DEFAULT_MAVEN_HOST
|
String hostedRepository = System.getenv("FLUTTER_STORAGE_BASE_URL") ?: DEFAULT_MAVEN_HOST
|
||||||
String repository = useLocalEngine()
|
String repository = useLocalEngine()
|
||||||
? project.property(propLocalEngineRepo)
|
? project.property(propLocalEngineRepo)
|
||||||
: "$hostedRepository/${engineRealm}download.flutter.io"
|
: "$hostedRepository/${engineRealm}download.flutter.io"
|
||||||
@ -239,11 +239,8 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String flutterVersionCode = localProperties.getProperty("flutter.versionCode")
|
extension.flutterVersionCode = localProperties.getProperty("flutter.versionCode", "1")
|
||||||
extension.flutterVersionCode = flutterVersionCode ?: "1"
|
extension.flutterVersionName = localProperties.getProperty("flutter.versionName", "1.0")
|
||||||
|
|
||||||
String flutterVersionName = localProperties.getProperty("flutter.versionName")
|
|
||||||
extension.flutterVersionName = flutterVersionName ?: "1.0"
|
|
||||||
|
|
||||||
this.addFlutterTasks(project)
|
this.addFlutterTasks(project)
|
||||||
forceNdkDownload(project, flutterRootPath)
|
forceNdkDownload(project, flutterRootPath)
|
||||||
@ -471,7 +468,7 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
// Warning: The name of this task is used by AndroidBuilder.outputsAppLinkSettings
|
// Warning: The name of this task is used by AndroidBuilder.outputsAppLinkSettings
|
||||||
project.tasks.register("output${variant.name.capitalize()}AppLinkSettings") {
|
project.tasks.register("output${variant.name.capitalize()}AppLinkSettings") {
|
||||||
description "stores app links settings for the given build variant of this Android project into a json file."
|
description "stores app links settings for the given build variant of this Android project into a json file."
|
||||||
variant.outputs.all { output ->
|
variant.outputs.configureEach { output ->
|
||||||
// Deeplinks are defined in AndroidManifest.xml and is only available after
|
// Deeplinks are defined in AndroidManifest.xml and is only available after
|
||||||
// `processResourcesProvider`.
|
// `processResourcesProvider`.
|
||||||
Object processResources = output.hasProperty(propProcessResourcesProvider) ?
|
Object processResources = output.hasProperty(propProcessResourcesProvider) ?
|
||||||
@ -482,7 +479,7 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
AppLinkSettings appLinkSettings = new AppLinkSettings()
|
AppLinkSettings appLinkSettings = new AppLinkSettings()
|
||||||
appLinkSettings.applicationId = variant.applicationId
|
appLinkSettings.applicationId = variant.applicationId
|
||||||
appLinkSettings.deeplinks = [] as Set<Deeplink>
|
appLinkSettings.deeplinks = [] as Set<Deeplink>
|
||||||
variant.outputs.all { output ->
|
variant.outputs.configureEach { output ->
|
||||||
Object processResources = output.hasProperty(propProcessResourcesProvider) ?
|
Object processResources = output.hasProperty(propProcessResourcesProvider) ?
|
||||||
output.processResourcesProvider.get() : output.processResources
|
output.processResourcesProvider.get() : output.processResources
|
||||||
def manifest = new XmlParser().parse(processResources.manifestFile)
|
def manifest = new XmlParser().parse(processResources.manifestFile)
|
||||||
@ -1011,9 +1008,7 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
if (localProperties == null) {
|
if (localProperties == null) {
|
||||||
localProperties = readPropertiesIfExist(new File(project.projectDir.parentFile, "local.properties"))
|
localProperties = readPropertiesIfExist(new File(project.projectDir.parentFile, "local.properties"))
|
||||||
}
|
}
|
||||||
String result = project.hasProperty(name) ? project.property(name) : null
|
return project.findProperty(name) ?: localProperties?.getProperty(name, defaultValue)
|
||||||
result = result ?: localProperties?.getProperty(name)
|
|
||||||
return result ?: defaultValue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getTargetPlatforms() {
|
private List<String> getTargetPlatforms() {
|
||||||
@ -1239,7 +1234,7 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
// for only the output APK, not for the variant itself. Skipping this step simply
|
// for only the output APK, not for the variant itself. Skipping this step simply
|
||||||
// causes Gradle to use the value of variant.versionCode for the APK.
|
// causes Gradle to use the value of variant.versionCode for the APK.
|
||||||
// For more, see https://developer.android.com/studio/build/configure-apk-splits
|
// For more, see https://developer.android.com/studio/build/configure-apk-splits
|
||||||
Integer abiVersionCode = ABI_VERSION.get(output.getFilter(OutputFile.ABI))
|
Integer abiVersionCode = ABI_VERSION[output.getFilter(OutputFile.ABI)]
|
||||||
if (abiVersionCode != null) {
|
if (abiVersionCode != null) {
|
||||||
output.versionCodeOverride =
|
output.versionCodeOverride =
|
||||||
abiVersionCode * 1000 + variant.versionCode
|
abiVersionCode * 1000 + variant.versionCode
|
||||||
@ -1304,7 +1299,7 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
validateDeferredComponents(validateDeferredComponentsValue)
|
validateDeferredComponents(validateDeferredComponentsValue)
|
||||||
flavor(flavorValue)
|
flavor(flavorValue)
|
||||||
}
|
}
|
||||||
Task compileTask = compileTaskProvider.get();
|
Task compileTask = compileTaskProvider.get()
|
||||||
File libJar = project.file(project.layout.buildDirectory.dir("$INTERMEDIATES_DIR/flutter/${variant.name}/libs.jar"))
|
File libJar = project.file(project.layout.buildDirectory.dir("$INTERMEDIATES_DIR/flutter/${variant.name}/libs.jar"))
|
||||||
TaskProvider<Jar> packJniLibsTaskProvider = project.tasks.register("packJniLibs${FLUTTER_BUILD_PREFIX}${variant.name.capitalize()}", Jar) {
|
TaskProvider<Jar> packJniLibsTaskProvider = project.tasks.register("packJniLibs${FLUTTER_BUILD_PREFIX}${variant.name.capitalize()}", Jar) {
|
||||||
destinationDirectory = libJar.parentFile
|
destinationDirectory = libJar.parentFile
|
||||||
@ -1331,7 +1326,7 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Task packJniLibsTask = packJniLibsTaskProvider.get();
|
Task packJniLibsTask = packJniLibsTaskProvider.get()
|
||||||
addApiDependencies(project, variant.name, project.files {
|
addApiDependencies(project, variant.name, project.files {
|
||||||
packJniLibsTask
|
packJniLibsTask
|
||||||
})
|
})
|
||||||
@ -1370,7 +1365,7 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
mergeAssets.mustRunAfter("clean${mergeAssets.name.capitalize()}")
|
mergeAssets.mustRunAfter("clean${mergeAssets.name.capitalize()}")
|
||||||
into(mergeAssets.outputDir)
|
into(mergeAssets.outputDir)
|
||||||
}
|
}
|
||||||
Task copyFlutterAssetsTask = copyFlutterAssetsTaskProvider.get();
|
Task copyFlutterAssetsTask = copyFlutterAssetsTaskProvider.get()
|
||||||
if (!isUsedAsSubproject) {
|
if (!isUsedAsSubproject) {
|
||||||
def variantOutput = variant.outputs.first()
|
def variantOutput = variant.outputs.first()
|
||||||
def processResources = variantOutput.hasProperty(propProcessResourcesProvider) ?
|
def processResources = variantOutput.hasProperty(propProcessResourcesProvider) ?
|
||||||
@ -1569,7 +1564,7 @@ class IntentFilterCheck {
|
|||||||
class Deeplink {
|
class Deeplink {
|
||||||
String scheme, host, path
|
String scheme, host, path
|
||||||
IntentFilterCheck intentFilterCheck
|
IntentFilterCheck intentFilterCheck
|
||||||
boolean equals(o) {
|
boolean equals(Object o) {
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
throw new NullPointerException()
|
throw new NullPointerException()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user