Skip to content

Commit 6facb96

Browse files
authored
Reland "Add support for Gradle Kotlin DSL (#140744)" (#142752)
This PR attempts to: - reland #140744 - reland #141541 (which is also in #142300 - I will close it once this PR is merged)
1 parent 3280be9 commit 6facb96

File tree

8 files changed

+244
-118
lines changed

8 files changed

+244
-118
lines changed

examples/hello_world/android/app/build.gradle

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
plugins {
6+
id("com.android.application")
7+
id("dev.flutter.flutter-gradle-plugin")
8+
}
9+
10+
android {
11+
namespace = "io.flutter.examples.hello_world"
12+
compileSdk = flutter.compileSdkVersion
13+
14+
compileOptions {
15+
sourceCompatibility = JavaVersion.VERSION_1_8
16+
targetCompatibility = JavaVersion.VERSION_1_8
17+
}
18+
19+
defaultConfig {
20+
applicationId = "io.flutter.examples.hello_world"
21+
minSdk = flutter.minSdkVersion
22+
targetSdk = flutter.targetSdkVersion
23+
versionCode = flutter.versionCode()
24+
versionName = flutter.versionName()
25+
}
26+
27+
buildTypes {
28+
named("release") {
29+
// TODO: Add your own signing config for the release build.
30+
// Signing with the debug keys for now, so `flutter run --release` works.
31+
signingConfig = signingConfigs.getByName("debug")
32+
}
33+
}
34+
}
35+
36+
flutter {
37+
source = "../.."
38+
}

examples/hello_world/android/build.gradle

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Contents of this file should be generated automatically by
6+
// dev/tools/bin/generate_gradle_lockfiles.dart, but currently are not.
7+
// See #141540.
8+
9+
allprojects {
10+
repositories {
11+
google()
12+
mavenCentral()
13+
}
14+
}
15+
16+
rootProject.buildDir = file("../build")
17+
18+
subprojects {
19+
project.buildDir = file("${rootProject.buildDir}/${project.name}")
20+
}
21+
subprojects {
22+
project.evaluationDependsOn(":app")
23+
dependencyLocking {
24+
ignoredDependencies.add("io.flutter:*")
25+
lockFile = file("${rootProject.projectDir}/project-${project.name}.lockfile")
26+
if (!project.hasProperty("local-engine-repo")) {
27+
lockAllConfigurations()
28+
}
29+
}
30+
}
31+
32+
tasks.register<Delete>("clean") {
33+
delete(rootProject.buildDir)
34+
}
Lines changed: 147 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,153 @@
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.4.2=classpath
5+
androidx.databinding:databinding-compiler-common:7.4.2=classpath
6+
com.android.application:com.android.application.gradle.plugin:7.4.2=classpath
7+
com.android.databinding:baseLibrary:7.4.2=classpath
8+
com.android.tools.analytics-library:crash:30.4.2=classpath
9+
com.android.tools.analytics-library:protos:30.4.2=classpath
10+
com.android.tools.analytics-library:shared:30.4.2=classpath
11+
com.android.tools.analytics-library:tracker:30.4.2=classpath
12+
com.android.tools.build.jetifier:jetifier-core:1.0.0-beta10=classpath
13+
com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta10=classpath
14+
com.android.tools.build:aapt2-proto:7.4.2-8841542=classpath
15+
com.android.tools.build:aaptcompiler:7.4.2=classpath
16+
com.android.tools.build:apksig:7.4.2=classpath
17+
com.android.tools.build:apkzlib:7.4.2=classpath
18+
com.android.tools.build:builder-model:7.4.2=classpath
19+
com.android.tools.build:builder-test-api:7.4.2=classpath
20+
com.android.tools.build:builder:7.4.2=classpath
21+
com.android.tools.build:bundletool:1.11.4=classpath
22+
com.android.tools.build:gradle-api:7.4.2=classpath
23+
com.android.tools.build:gradle-settings-api:7.4.2=classpath
24+
com.android.tools.build:gradle:7.4.2=classpath
25+
com.android.tools.build:manifest-merger:30.4.2=classpath
26+
com.android.tools.build:transform-api:2.0.0-deprecated-use-gradle-api=classpath
27+
com.android.tools.ddms:ddmlib:30.4.2=classpath
28+
com.android.tools.layoutlib:layoutlib-api:30.4.2=classpath
29+
com.android.tools.lint:lint-model:30.4.2=classpath
30+
com.android.tools.lint:lint-typedef-remover:30.4.2=classpath
31+
com.android.tools.utp:android-device-provider-ddmlib-proto:30.4.2=classpath
32+
com.android.tools.utp:android-device-provider-gradle-proto:30.4.2=classpath
33+
com.android.tools.utp:android-test-plugin-host-additional-test-output-proto:30.4.2=classpath
34+
com.android.tools.utp:android-test-plugin-host-coverage-proto:30.4.2=classpath
35+
com.android.tools.utp:android-test-plugin-host-retention-proto:30.4.2=classpath
36+
com.android.tools.utp:android-test-plugin-result-listener-gradle-proto:30.4.2=classpath
37+
com.android.tools:annotations:30.4.2=classpath
38+
com.android.tools:common:30.4.2=classpath
39+
com.android.tools:dvlib:30.4.2=classpath
40+
com.android.tools:repository:30.4.2=classpath
41+
com.android.tools:sdk-common:30.4.2=classpath
42+
com.android.tools:sdklib:30.4.2=classpath
43+
com.android:signflinger:7.4.2=classpath
44+
com.android:zipflinger:7.4.2=classpath
45+
com.github.gundy:semver4j:0.16.4=classpath
46+
com.google.android:annotations:4.1.1.4=classpath
47+
com.google.api.grpc:proto-google-common-protos:2.0.1=classpath
48+
com.google.auto.value:auto-value-annotations:1.6.2=classpath
49+
com.google.code.findbugs:jsr305:3.0.2=classpath
50+
com.google.code.gson:gson:2.8.9=classpath
51+
com.google.crypto.tink:tink:1.3.0-rc2=classpath
52+
com.google.dagger:dagger:2.28.3=classpath
53+
com.google.errorprone:error_prone_annotations:2.4.0=classpath
54+
com.google.flatbuffers:flatbuffers-java:1.12.0=classpath
55+
com.google.guava:failureaccess:1.0.1=classpath
56+
com.google.guava:guava:30.1-jre=classpath
57+
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=classpath
58+
com.google.j2objc:j2objc-annotations:1.3=classpath
59+
com.google.jimfs:jimfs:1.1=classpath
60+
com.google.protobuf:protobuf-java-util:3.17.2=classpath
61+
com.google.protobuf:protobuf-java:3.17.2=classpath
62+
com.google.testing.platform:core-proto:0.0.8-alpha08=classpath
63+
com.googlecode.juniversalchardet:juniversalchardet:1.0.3=classpath
64+
com.squareup:javapoet:1.10.0=classpath
65+
com.squareup:javawriter:2.5.0=classpath
66+
com.sun.activation:javax.activation:1.2.0=classpath
67+
com.sun.istack:istack-commons-runtime:3.0.8=classpath
68+
com.sun.xml.fastinfoset:FastInfoset:1.2.16=classpath
69+
commons-codec:commons-codec:1.11=classpath
70+
commons-io:commons-io:2.4=classpath
71+
commons-logging:commons-logging:1.2=classpath
72+
de.undercouch:gradle-download-task:4.1.1=classpath
73+
io.grpc:grpc-api:1.39.0=classpath
74+
io.grpc:grpc-context:1.39.0=classpath
75+
io.grpc:grpc-core:1.39.0=classpath
76+
io.grpc:grpc-netty:1.39.0=classpath
77+
io.grpc:grpc-protobuf-lite:1.39.0=classpath
78+
io.grpc:grpc-protobuf:1.39.0=classpath
79+
io.grpc:grpc-stub:1.39.0=classpath
80+
io.netty:netty-buffer:4.1.52.Final=classpath
81+
io.netty:netty-codec-http2:4.1.52.Final=classpath
82+
io.netty:netty-codec-http:4.1.52.Final=classpath
83+
io.netty:netty-codec-socks:4.1.52.Final=classpath
84+
io.netty:netty-codec:4.1.52.Final=classpath
85+
io.netty:netty-common:4.1.52.Final=classpath
86+
io.netty:netty-handler-proxy:4.1.52.Final=classpath
87+
io.netty:netty-handler:4.1.52.Final=classpath
88+
io.netty:netty-resolver:4.1.52.Final=classpath
89+
io.netty:netty-transport:4.1.52.Final=classpath
90+
io.perfmark:perfmark-api:0.23.0=classpath
91+
jakarta.activation:jakarta.activation-api:1.2.1=classpath
92+
jakarta.xml.bind:jakarta.xml.bind-api:2.3.2=classpath
93+
javax.annotation:javax.annotation-api:1.3.2=classpath
94+
javax.inject:javax.inject:1=classpath
95+
net.java.dev.jna:jna-platform:5.6.0=classpath
96+
net.java.dev.jna:jna:5.6.0=classpath
97+
net.sf.jopt-simple:jopt-simple:4.9=classpath
98+
net.sf.kxml:kxml2:2.3.0=classpath
99+
org.apache.commons:commons-compress:1.20=classpath
100+
org.apache.httpcomponents:httpclient:4.5.13=classpath
101+
org.apache.httpcomponents:httpcore:4.4.13=classpath
102+
org.apache.httpcomponents:httpmime:4.5.6=classpath
103+
org.bitbucket.b_c:jose4j:0.7.0=classpath
104+
org.bouncycastle:bcpkix-jdk15on:1.67=classpath
105+
org.bouncycastle:bcprov-jdk15on:1.67=classpath
106+
org.checkerframework:checker-qual:3.5.0=classpath
107+
org.codehaus.mojo:animal-sniffer-annotations:1.19=classpath
108+
org.glassfish.jaxb:jaxb-runtime:2.3.2=classpath
109+
org.glassfish.jaxb:txw2:2.3.2=classpath
110+
org.jdom:jdom2:2.0.6=classpath
4111
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
112+
org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.7.10=classpath
113+
org.jetbrains.kotlin:kotlin-android-extensions:1.7.10=classpath
114+
org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.7.10=classpath
115+
org.jetbrains.kotlin:kotlin-build-common:1.7.10=classpath
116+
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=classpath
117+
org.jetbrains.kotlin:kotlin-compiler-runner:1.7.10=classpath
118+
org.jetbrains.kotlin:kotlin-daemon-client:1.7.10=classpath
119+
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=classpath
120+
org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.10=classpath
121+
org.jetbrains.kotlin:kotlin-gradle-plugin-idea:1.7.10=classpath
122+
org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.7.10=classpath
123+
org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10=classpath
124+
org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.7.10=classpath
125+
org.jetbrains.kotlin:kotlin-native-utils:1.7.10=classpath
126+
org.jetbrains.kotlin:kotlin-project-model:1.7.10=classpath
127+
org.jetbrains.kotlin:kotlin-reflect:1.8.20=classpath
128+
org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=classpath
129+
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=classpath
130+
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=classpath
131+
org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=classpath
132+
org.jetbrains.kotlin:kotlin-stdlib-common:1.8.20=classpath
133+
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.20=classpath
134+
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.20=classpath
135+
org.jetbrains.kotlin:kotlin-stdlib:1.8.20=classpath
136+
org.jetbrains.kotlin:kotlin-tooling-core:1.7.10=classpath
137+
org.jetbrains.kotlin:kotlin-tooling-metadata:1.7.10=classpath
138+
org.jetbrains.kotlin:kotlin-util-io:1.7.10=classpath
139+
org.jetbrains.kotlin:kotlin-util-klib:1.7.10=classpath
28140
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=classpath
141+
org.jetbrains:annotations:13.0=classpath
142+
org.json:json:20180813=classpath
143+
org.jvnet.staxex:stax-ex:1.8.1=classpath
144+
org.ow2.asm:asm-analysis:9.2=classpath
145+
org.ow2.asm:asm-commons:9.2=classpath
146+
org.ow2.asm:asm-tree:9.2=classpath
147+
org.ow2.asm:asm-util:9.2=classpath
148+
org.ow2.asm:asm:9.2=classpath
149+
org.slf4j:slf4j-api:1.7.30=classpath
150+
org.tensorflow:tensorflow-lite-metadata:0.1.0-rc2=classpath
151+
xerces:xercesImpl:2.12.0=classpath
152+
xml-apis:xml-apis:1.4.01=classpath
29153
empty=

examples/hello_world/android/settings.gradle.kts

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

5-
// Contents of this file automatically generated by dev/tools/bin/generate_gradle_lockfiles.dart.
6-
// Do not merge changes to this file. See #140115.
5+
// Contents of this file should be generated automatically by
6+
// dev/tools/bin/generate_gradle_lockfiles.dart, but currently are not.
7+
// See #141540.
78

89
pluginManagement {
910
val flutterSdkPath = run {
@@ -23,9 +24,17 @@ pluginManagement {
2324
}
2425
}
2526

27+
buildscript {
28+
dependencyLocking {
29+
lockFile = file("${rootProject.projectDir}/buildscript-gradle.lockfile")
30+
lockAllConfigurations()
31+
}
32+
}
33+
2634
plugins {
2735
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
2836
id("com.android.application") version "7.4.2" apply false
37+
id("org.jetbrains.kotlin.android") version "1.7.10" apply false
2938
}
3039

3140
include(":app")

packages/flutter_tools/gradle/src/main/groovy/flutter.groovy

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,11 +762,20 @@ class FlutterPlugin implements Plugin<Project> {
762762
}
763763

764764
/**
765-
* Returns `true` if the given path contains an `android/build.gradle` file.
765+
* Returns `true` if the given path contains an `android` directory
766+
* containing a `build.gradle` or `build.gradle.kts` file.
766767
*/
767768
private Boolean doesSupportAndroidPlatform(String path) {
768-
File editableAndroidProject = new File(path, 'android' + File.separator + 'build.gradle')
769-
return editableAndroidProject.exists()
769+
File buildGradle = new File(path, 'android' + File.separator + 'build.gradle')
770+
File buildGradleKts = new File(path, 'android' + File.separator + 'build.gradle.kts')
771+
if (buildGradle.exists() && buildGradleKts.exists()) {
772+
logger.error(
773+
"Both build.gradle and build.gradle.kts exist, so " +
774+
"build.gradle.kts is ignored. This is likely a mistake."
775+
)
776+
}
777+
778+
return buildGradle.exists() || buildGradleKts.exists()
770779
}
771780

772781
/**

0 commit comments

Comments
 (0)