Skip to content

Commit dbe0ccd

Browse files
authored
Refactor "app plugin loader" Gradle Plugin so it can be applied using the declarative plugins {} block (#127897)
This PR fixes #125009.
1 parent 74c6693 commit dbe0ccd

File tree

13 files changed

+116
-212
lines changed

13 files changed

+116
-212
lines changed

examples/hello_world/android/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
// See dev/tools/bin/generate_gradle_lockfiles.dart.
88

99
buildscript {
10-
ext.kotlin_version = '1.5.31'
10+
ext.kotlin_version = '1.9.0'
1111
repositories {
1212
google()
1313
mavenCentral()
1414
}
1515

1616
dependencies {
17-
classpath 'com.android.tools.build:gradle:7.2.0'
1817
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1918
}
2019

Lines changed: 24 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -1,163 +1,29 @@
11
# This is a Gradle generated file for dependency locking.
22
# Manual edits can break the build and are not advised.
33
# This file is expected to be part of source control.
4-
androidx.databinding:databinding-common:7.2.0=classpath
5-
androidx.databinding:databinding-compiler-common:7.2.0=classpath
6-
com.android.databinding:baseLibrary:7.2.0=classpath
7-
com.android.tools.analytics-library:crash:30.2.0=classpath
8-
com.android.tools.analytics-library:protos:30.2.0=classpath
9-
com.android.tools.analytics-library:shared:30.2.0=classpath
10-
com.android.tools.analytics-library:tracker:30.2.0=classpath
11-
com.android.tools.build.jetifier:jetifier-core:1.0.0-beta09=classpath
12-
com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta09=classpath
13-
com.android.tools.build:aapt2-proto:7.2.0-7984345=classpath
14-
com.android.tools.build:aaptcompiler:7.2.0=classpath
15-
com.android.tools.build:apksig:7.2.0=classpath
16-
com.android.tools.build:apkzlib:7.2.0=classpath
17-
com.android.tools.build:builder-model:7.2.0=classpath
18-
com.android.tools.build:builder-test-api:7.2.0=classpath
19-
com.android.tools.build:builder:7.2.0=classpath
20-
com.android.tools.build:bundletool:1.8.2=classpath
21-
com.android.tools.build:gradle-api:7.2.0=classpath
22-
com.android.tools.build:gradle:7.2.0=classpath
23-
com.android.tools.build:manifest-merger:30.2.0=classpath
24-
com.android.tools.build:transform-api:2.0.0-deprecated-use-gradle-api=classpath
25-
com.android.tools.ddms:ddmlib:30.2.0=classpath
26-
com.android.tools.layoutlib:layoutlib-api:30.2.0=classpath
27-
com.android.tools.lint:lint-model:30.2.0=classpath
28-
com.android.tools.lint:lint-typedef-remover:30.2.0=classpath
29-
com.android.tools.utp:android-device-provider-ddmlib-proto:30.2.0=classpath
30-
com.android.tools.utp:android-device-provider-gradle-proto:30.2.0=classpath
31-
com.android.tools.utp:android-test-plugin-host-additional-test-output-proto:30.2.0=classpath
32-
com.android.tools.utp:android-test-plugin-host-coverage-proto:30.2.0=classpath
33-
com.android.tools.utp:android-test-plugin-host-retention-proto:30.2.0=classpath
34-
com.android.tools.utp:android-test-plugin-result-listener-gradle-proto:30.2.0=classpath
35-
com.android.tools:annotations:30.2.0=classpath
36-
com.android.tools:common:30.2.0=classpath
37-
com.android.tools:dvlib:30.2.0=classpath
38-
com.android.tools:repository:30.2.0=classpath
39-
com.android.tools:sdk-common:30.2.0=classpath
40-
com.android.tools:sdklib:30.2.0=classpath
41-
com.android:signflinger:7.2.0=classpath
42-
com.android:zipflinger:7.2.0=classpath
43-
com.fasterxml.jackson.core:jackson-annotations:2.11.1=classpath
44-
com.fasterxml.jackson.core:jackson-core:2.11.1=classpath
45-
com.fasterxml.jackson.core:jackson-databind:2.11.1=classpath
46-
com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.11.1=classpath
47-
com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.11.1=classpath
48-
com.fasterxml.jackson.module:jackson-module-kotlin:2.11.1=classpath
49-
com.fasterxml.woodstox:woodstox-core:6.2.1=classpath
50-
com.github.gundy:semver4j:0.16.4=classpath
51-
com.google.android:annotations:4.1.1.4=classpath
52-
com.google.api.grpc:proto-google-common-protos:1.12.0=classpath
53-
com.google.auto.value:auto-value-annotations:1.6.2=classpath
54-
com.google.code.findbugs:jsr305:3.0.2=classpath
55-
com.google.code.gson:gson:2.8.6=classpath
56-
com.google.crypto.tink:tink:1.3.0-rc2=classpath
57-
com.google.dagger:dagger:2.28.3=classpath
58-
com.google.errorprone:error_prone_annotations:2.3.4=classpath
59-
com.google.flatbuffers:flatbuffers-java:1.12.0=classpath
60-
com.google.guava:failureaccess:1.0.1=classpath
61-
com.google.guava:guava:30.1-jre=classpath
62-
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=classpath
63-
com.google.j2objc:j2objc-annotations:1.3=classpath
64-
com.google.jimfs:jimfs:1.1=classpath
65-
com.google.protobuf:protobuf-java-util:3.10.0=classpath
66-
com.google.protobuf:protobuf-java:3.10.0=classpath
67-
com.google.testing.platform:core-proto:0.0.8-alpha07=classpath
68-
com.googlecode.json-simple:json-simple:1.1=classpath
69-
com.googlecode.juniversalchardet:juniversalchardet:1.0.3=classpath
70-
com.squareup:javapoet:1.10.0=classpath
71-
com.squareup:javawriter:2.5.0=classpath
72-
com.sun.activation:javax.activation:1.2.0=classpath
73-
com.sun.istack:istack-commons-runtime:3.0.8=classpath
74-
com.sun.xml.fastinfoset:FastInfoset:1.2.16=classpath
75-
commons-codec:commons-codec:1.11=classpath
76-
commons-io:commons-io:2.4=classpath
77-
commons-logging:commons-logging:1.2=classpath
78-
de.undercouch:gradle-download-task:4.1.1=classpath
79-
io.grpc:grpc-api:1.21.1=classpath
80-
io.grpc:grpc-context:1.21.1=classpath
81-
io.grpc:grpc-core:1.21.1=classpath
82-
io.grpc:grpc-netty:1.21.1=classpath
83-
io.grpc:grpc-protobuf-lite:1.21.1=classpath
84-
io.grpc:grpc-protobuf:1.21.1=classpath
85-
io.grpc:grpc-stub:1.21.1=classpath
86-
io.netty:netty-buffer:4.1.34.Final=classpath
87-
io.netty:netty-codec-http2:4.1.34.Final=classpath
88-
io.netty:netty-codec-http:4.1.34.Final=classpath
89-
io.netty:netty-codec-socks:4.1.34.Final=classpath
90-
io.netty:netty-codec:4.1.34.Final=classpath
91-
io.netty:netty-common:4.1.34.Final=classpath
92-
io.netty:netty-handler-proxy:4.1.34.Final=classpath
93-
io.netty:netty-handler:4.1.34.Final=classpath
94-
io.netty:netty-resolver:4.1.34.Final=classpath
95-
io.netty:netty-transport:4.1.34.Final=classpath
96-
io.opencensus:opencensus-api:0.21.0=classpath
97-
io.opencensus:opencensus-contrib-grpc-metrics:0.21.0=classpath
98-
it.unimi.dsi:fastutil:8.4.0=classpath
99-
jakarta.activation:jakarta.activation-api:1.2.1=classpath
100-
jakarta.xml.bind:jakarta.xml.bind-api:2.3.2=classpath
101-
javax.inject:javax.inject:1=classpath
102-
net.java.dev.jna:jna-platform:5.6.0=classpath
103-
net.java.dev.jna:jna:5.6.0=classpath
104-
net.sf.jopt-simple:jopt-simple:4.9=classpath
105-
net.sf.kxml:kxml2:2.3.0=classpath
106-
org.apache.commons:commons-compress:1.20=classpath
107-
org.apache.httpcomponents:httpclient:4.5.9=classpath
108-
org.apache.httpcomponents:httpcore:4.4.11=classpath
109-
org.apache.httpcomponents:httpmime:4.5.6=classpath
110-
org.bitbucket.b_c:jose4j:0.7.0=classpath
111-
org.bouncycastle:bcpkix-jdk15on:1.56=classpath
112-
org.bouncycastle:bcprov-jdk15on:1.56=classpath
113-
org.checkerframework:checker-qual:3.5.0=classpath
114-
org.codehaus.mojo:animal-sniffer-annotations:1.17=classpath
115-
org.codehaus.woodstox:stax2-api:4.2.1=classpath
116-
org.glassfish.jaxb:jaxb-runtime:2.3.2=classpath
117-
org.glassfish.jaxb:txw2:2.3.2=classpath
118-
org.jdom:jdom2:2.0.6=classpath
119-
org.jetbrains.dokka:dokka-core:1.4.32=classpath
120-
org.jetbrains.intellij.deps:trove4j:1.0.20181211=classpath
121-
org.jetbrains.kotlin:kotlin-android-extensions:1.5.31=classpath
122-
org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.5.31=classpath
123-
org.jetbrains.kotlin:kotlin-build-common:1.5.31=classpath
124-
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.31=classpath
125-
org.jetbrains.kotlin:kotlin-compiler-runner:1.5.31=classpath
126-
org.jetbrains.kotlin:kotlin-daemon-client:1.5.31=classpath
127-
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.5.31=classpath
128-
org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.5.31=classpath
129-
org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.5.31=classpath
130-
org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31=classpath
131-
org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.5.31=classpath
132-
org.jetbrains.kotlin:kotlin-native-utils:1.5.31=classpath
133-
org.jetbrains.kotlin:kotlin-project-model:1.5.31=classpath
134-
org.jetbrains.kotlin:kotlin-reflect:1.5.31=classpath
135-
org.jetbrains.kotlin:kotlin-scripting-common:1.5.31=classpath
136-
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.5.31=classpath
137-
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.5.31=classpath
138-
org.jetbrains.kotlin:kotlin-scripting-jvm:1.5.31=classpath
139-
org.jetbrains.kotlin:kotlin-stdlib-common:1.5.31=classpath
140-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.31=classpath
141-
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31=classpath
142-
org.jetbrains.kotlin:kotlin-stdlib:1.5.31=classpath
143-
org.jetbrains.kotlin:kotlin-tooling-metadata:1.5.31=classpath
144-
org.jetbrains.kotlin:kotlin-util-io:1.5.31=classpath
145-
org.jetbrains.kotlin:kotlin-util-klib:1.5.31=classpath
4+
org.jetbrains.intellij.deps:trove4j:1.0.20200330=classpath
5+
org.jetbrains.kotlin:kotlin-android-extensions:1.9.0=classpath
6+
org.jetbrains.kotlin:kotlin-build-tools-api:1.9.0=classpath
7+
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.0=classpath
8+
org.jetbrains.kotlin:kotlin-compiler-runner:1.9.0=classpath
9+
org.jetbrains.kotlin:kotlin-daemon-client:1.9.0=classpath
10+
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.0=classpath
11+
org.jetbrains.kotlin:kotlin-gradle-plugin-annotations:1.9.0=classpath
12+
org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.9.0=classpath
13+
org.jetbrains.kotlin:kotlin-gradle-plugin-idea-proto:1.9.0=classpath
14+
org.jetbrains.kotlin:kotlin-gradle-plugin-idea:1.9.0=classpath
15+
org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.9.0=classpath
16+
org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0=classpath
17+
org.jetbrains.kotlin:kotlin-gradle-plugins-bom:1.9.0=classpath
18+
org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.9.0=classpath
19+
org.jetbrains.kotlin:kotlin-native-utils:1.9.0=classpath
20+
org.jetbrains.kotlin:kotlin-project-model:1.9.0=classpath
21+
org.jetbrains.kotlin:kotlin-scripting-common:1.9.0=classpath
22+
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.9.0=classpath
23+
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.9.0=classpath
24+
org.jetbrains.kotlin:kotlin-scripting-jvm:1.9.0=classpath
25+
org.jetbrains.kotlin:kotlin-tooling-core:1.9.0=classpath
26+
org.jetbrains.kotlin:kotlin-util-io:1.9.0=classpath
27+
org.jetbrains.kotlin:kotlin-util-klib:1.9.0=classpath
14628
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=classpath
147-
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0=classpath
148-
org.jetbrains:annotations:13.0=classpath
149-
org.jetbrains:markdown-jvm:0.2.1=classpath
150-
org.jetbrains:markdown:0.2.1=classpath
151-
org.json:json:20180813=classpath
152-
org.jsoup:jsoup:1.13.1=classpath
153-
org.jvnet.staxex:stax-ex:1.8.1=classpath
154-
org.ow2.asm:asm-analysis:9.1=classpath
155-
org.ow2.asm:asm-commons:9.1=classpath
156-
org.ow2.asm:asm-tree:9.1=classpath
157-
org.ow2.asm:asm-util:9.1=classpath
158-
org.ow2.asm:asm:9.1=classpath
159-
org.slf4j:slf4j-api:1.7.30=classpath
160-
org.tensorflow:tensorflow-lite-metadata:0.1.0-rc2=classpath
161-
xerces:xercesImpl:2.12.0=classpath
162-
xml-apis:xml-apis:1.4.01=classpath
16329
empty=

examples/hello_world/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip

examples/hello_world/android/project-app.lockfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ org.codehaus.groovy:groovy-all:2.4.15=lintClassPath
8787
org.codehaus.mojo:animal-sniffer-annotations:1.18=lintClassPath
8888
org.glassfish.jaxb:jaxb-runtime:2.3.1=lintClassPath
8989
org.glassfish.jaxb:txw2:2.3.1=lintClassPath
90-
org.jacoco:org.jacoco.agent:0.8.7=androidJacocoAnt
91-
org.jacoco:org.jacoco.ant:0.8.7=androidJacocoAnt
92-
org.jacoco:org.jacoco.core:0.8.7=androidJacocoAnt
93-
org.jacoco:org.jacoco.report:0.8.7=androidJacocoAnt
90+
org.jacoco:org.jacoco.agent:0.8.8=androidJacocoAnt
91+
org.jacoco:org.jacoco.ant:0.8.8=androidJacocoAnt
92+
org.jacoco:org.jacoco.core:0.8.8=androidJacocoAnt
93+
org.jacoco:org.jacoco.report:0.8.8=androidJacocoAnt
9494
org.jetbrains.kotlin:kotlin-reflect:1.3.72=lintClassPath
9595
org.jetbrains.kotlin:kotlin-stdlib-common:1.3.72=lintClassPath
9696
org.jetbrains.kotlin:kotlin-stdlib-common:1.5.31=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath
@@ -107,12 +107,12 @@ org.jetbrains.trove4j:trove4j:20160824=lintClassPath
107107
org.jetbrains:annotations:13.0=debugAndroidTestCompileClasspath,debugCompileClasspath,debugRuntimeClasspath,debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,lintClassPath,profileCompileClasspath,profileRuntimeClasspath,profileUnitTestCompileClasspath,profileUnitTestRuntimeClasspath,releaseCompileClasspath,releaseRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath
108108
org.jvnet.staxex:stax-ex:1.8=lintClassPath
109109
org.ow2.asm:asm-analysis:7.0=lintClassPath
110-
org.ow2.asm:asm-analysis:9.1=androidJacocoAnt
110+
org.ow2.asm:asm-analysis:9.2=androidJacocoAnt
111111
org.ow2.asm:asm-commons:7.0=lintClassPath
112-
org.ow2.asm:asm-commons:9.1=androidJacocoAnt
112+
org.ow2.asm:asm-commons:9.2=androidJacocoAnt
113113
org.ow2.asm:asm-tree:7.0=lintClassPath
114-
org.ow2.asm:asm-tree:9.1=androidJacocoAnt
114+
org.ow2.asm:asm-tree:9.2=androidJacocoAnt
115115
org.ow2.asm:asm-util:7.0=lintClassPath
116116
org.ow2.asm:asm:7.0=lintClassPath
117-
org.ow2.asm:asm:9.1=androidJacocoAnt
117+
org.ow2.asm:asm:9.2=androidJacocoAnt
118118
empty=androidApis,androidJdkImage,androidTestUtil,compile,coreLibraryDesugaring,debugAndroidTestAnnotationProcessorClasspath,debugAndroidTestRuntimeClasspath,debugAnnotationProcessorClasspath,debugReverseMetadataValues,debugUnitTestAnnotationProcessorClasspath,debugWearBundling,lintChecks,lintPublish,profileAnnotationProcessorClasspath,profileReverseMetadataValues,profileUnitTestAnnotationProcessorClasspath,profileWearBundling,releaseAnnotationProcessorClasspath,releaseReverseMetadataValues,releaseUnitTestAnnotationProcessorClasspath,releaseWearBundling,testCompile

examples/hello_world/android/settings.gradle

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ pluginManagement {
1919
// Flutter Gradle Plugin ships together with the Flutter SDK
2020
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
2121

22+
repositories {
23+
google()
24+
mavenCentral()
25+
gradlePluginPortal()
26+
}
27+
2228
plugins {
2329
// Flutter Gradle Plugin's ID is defined in /packages/flutter_tools/gradle/build.gradle.kts.
2430
// We set `apply false`, because we don't want to apply the plugin to
@@ -27,6 +33,9 @@ pluginManagement {
2733
}
2834
}
2935

30-
include ':app'
36+
plugins {
37+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
38+
id "com.android.application" version "7.4.2" apply false
39+
}
3140

32-
apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle"
41+
include ':app'

packages/flutter_tools/gradle/app_plugin_loader.gradle

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// This file is included from `<app>/android/settings.gradle`,
6-
// so it can be versioned with the Flutter SDK.
5+
// This file exists solely for the compatibility with projects that have
6+
// not migrated to the declarative apply of the Flutter App Plugin Loader Gradle Plugin.
77

8-
import groovy.json.JsonSlurper
9-
10-
def flutterProjectRoot = rootProject.projectDir.parentFile
11-
12-
// If this logic is changed, also change the logic in module_plugin_loader.gradle.
13-
def pluginsFile = new File(flutterProjectRoot, '.flutter-plugins-dependencies')
14-
if (!pluginsFile.exists()) {
15-
return
16-
}
17-
18-
def object = new JsonSlurper().parseText(pluginsFile.text)
19-
assert object instanceof Map
20-
assert object.plugins instanceof Map
21-
assert object.plugins.android instanceof List
22-
// Includes the Flutter plugins that support the Android platform.
23-
object.plugins.android.each { androidPlugin ->
24-
assert androidPlugin.name instanceof String
25-
assert androidPlugin.path instanceof String
26-
// Skip plugins that have no native build (such as a Dart-only implementation
27-
// of a federated plugin).
28-
def needsBuild = androidPlugin.containsKey('native_build') ? androidPlugin['native_build'] : true
29-
if (!needsBuild) {
30-
return
31-
}
32-
def pluginDirectory = new File(androidPlugin.path, 'android')
33-
assert pluginDirectory.exists()
34-
include ":${androidPlugin.name}"
35-
project(":${androidPlugin.name}").projectDir = pluginDirectory
36-
}
8+
def pathToThisDirectory = buildscript.sourceFile.parentFile
9+
apply from: "$pathToThisDirectory/src/main/groovy/app_plugin_loader.groovy"

packages/flutter_tools/gradle/build.gradle.kts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
// found in the LICENSE file.
44

55
plugins {
6-
`groovy-gradle-plugin`
7-
}
8-
9-
repositories {
10-
google()
11-
mavenCentral()
6+
`java-gradle-plugin`
7+
`groovy`
128
}
139

1410

@@ -22,6 +18,10 @@ gradlePlugin {
2218
id = "dev.flutter.flutter-gradle-plugin"
2319
implementationClass = "FlutterPlugin"
2420
}
21+
create("flutterAppPluginLoaderPlugin") {
22+
id = "dev.flutter.flutter-plugin-loader"
23+
implementationClass = "FlutterAppPluginLoaderPlugin"
24+
}
2525
}
2626
}
2727

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dependencyResolutionManagement {
2+
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
3+
repositories {
4+
google()
5+
mavenCentral()
6+
}
7+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import groovy.json.JsonSlurper
2+
import org.gradle.api.Plugin
3+
import org.gradle.api.initialization.Settings
4+
5+
apply plugin: FlutterAppPluginLoaderPlugin
6+
7+
class FlutterAppPluginLoaderPlugin implements Plugin<Settings> {
8+
// This string must match _kFlutterPluginsHasNativeBuildKey defined in
9+
// packages/flutter_tools/lib/src/flutter_plugins.dart.
10+
private final String nativeBuildKey = 'native_build'
11+
12+
@Override
13+
void apply(Settings settings) {
14+
def flutterProjectRoot = settings.settingsDir.parentFile
15+
16+
// If this logic is changed, also change the logic in module_plugin_loader.gradle.
17+
def pluginsFile = new File(flutterProjectRoot, '.flutter-plugins-dependencies')
18+
if (!pluginsFile.exists()) {
19+
return
20+
}
21+
22+
def object = new JsonSlurper().parseText(pluginsFile.text)
23+
assert object instanceof Map
24+
assert object.plugins instanceof Map
25+
assert object.plugins.android instanceof List
26+
// Includes the Flutter plugins that support the Android platform.
27+
object.plugins.android.each { androidPlugin ->
28+
assert androidPlugin.name instanceof String
29+
assert androidPlugin.path instanceof String
30+
// Skip plugins that have no native build (such as a Dart-only implementation
31+
// of a federated plugin).
32+
def needsBuild = androidPlugin.containsKey(nativeBuildKey) ? androidPlugin[nativeBuildKey] : true
33+
if (!needsBuild) {
34+
return
35+
}
36+
def pluginDirectory = new File(androidPlugin.path, 'android')
37+
assert pluginDirectory.exists()
38+
settings.include(":${androidPlugin.name}")
39+
settings.project(":${androidPlugin.name}").projectDir = pluginDirectory
40+
}
41+
}
42+
}

packages/flutter_tools/templates/app_shared/android-java.tmpl/build.gradle.tmpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ buildscript {
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
109
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1110
}
1211
}

0 commit comments

Comments
 (0)