From b258ca011ef92093f4268e1dc8765eba30f07f4e Mon Sep 17 00:00:00 2001 From: "auto-submit[bot]" <98614782+auto-submit[bot]@users.noreply.github.com> Date: Tue, 23 Jan 2024 00:01:17 +0000 Subject: [PATCH] Reverts "hello_world app: migrate to Gradle Kotlin DSL" (#142018) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverts flutter/flutter#141541 Initiated by: yusuf-goog This change reverts the following previous change: Original Description: This PR introduces the first app in this repo that fully uses Gradle Kotlin DSL. It also fixes a bug I found in the process – fields of `FlutterExtensions` must be `public`. --- examples/hello_world/android/app/build.gradle | 38 ++++ .../hello_world/android/app/build.gradle.kts | 38 ---- examples/hello_world/android/build.gradle | 50 ++++++ examples/hello_world/android/build.gradle.kts | 34 ---- .../android/buildscript-gradle.lockfile | 170 +++--------------- .../hello_world/android/settings.gradle.kts | 13 +- .../gradle/src/main/groovy/flutter.groovy | 12 +- 7 files changed, 119 insertions(+), 236 deletions(-) create mode 100644 examples/hello_world/android/app/build.gradle delete mode 100644 examples/hello_world/android/app/build.gradle.kts create mode 100644 examples/hello_world/android/build.gradle delete mode 100644 examples/hello_world/android/build.gradle.kts diff --git a/examples/hello_world/android/app/build.gradle b/examples/hello_world/android/app/build.gradle new file mode 100644 index 00000000000..5d571d1d78e --- /dev/null +++ b/examples/hello_world/android/app/build.gradle @@ -0,0 +1,38 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +plugins { + id "com.android.application" + id "dev.flutter.flutter-gradle-plugin" +} + +android { + namespace "io.flutter.examples.hello_world" + compileSdk flutter.compileSdkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + applicationId "io.flutter.examples.hello_world" + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutter.versionCode() + versionName flutter.versionName() + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} diff --git a/examples/hello_world/android/app/build.gradle.kts b/examples/hello_world/android/app/build.gradle.kts deleted file mode 100644 index 6732ca6873f..00000000000 --- a/examples/hello_world/android/app/build.gradle.kts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -plugins { - id("com.android.application") - id("dev.flutter.flutter-gradle-plugin") -} - -android { - namespace = "io.flutter.examples.hello_world" - compileSdk = flutter.compileSdkVersion - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - - defaultConfig { - applicationId = "io.flutter.examples.hello_world" - minSdk = flutter.minSdkVersion - targetSdk = flutter.targetSdkVersion - versionCode = flutter.versionCode() - versionName = flutter.versionName() - } - - buildTypes { - named("release") { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig = signingConfigs.getByName("debug") - } - } -} - -flutter { - source = "../.." -} diff --git a/examples/hello_world/android/build.gradle b/examples/hello_world/android/build.gradle new file mode 100644 index 00000000000..a38857e025b --- /dev/null +++ b/examples/hello_world/android/build.gradle @@ -0,0 +1,50 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is auto generated. +// To update all the build.gradle files in the Flutter repo, +// See dev/tools/bin/generate_gradle_lockfiles.dart. + +buildscript { + ext.kotlin_version = '1.9.0' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } + + configurations.classpath { + resolutionStrategy.activateDependencyLocking() + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' + +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') + dependencyLocking { + ignoredDependencies.add('io.flutter:*') + lockFile = file("${rootProject.projectDir}/project-${project.name}.lockfile") + if (!project.hasProperty('local-engine-repo')) { + lockAllConfigurations() + } + } +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/examples/hello_world/android/build.gradle.kts b/examples/hello_world/android/build.gradle.kts deleted file mode 100644 index 14a09aa756a..00000000000 --- a/examples/hello_world/android/build.gradle.kts +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Contents of this file should be generated automatically by -// dev/tools/bin/generate_gradle_lockfiles.dart, but currently are not. -// See #141540. - -allprojects { - repositories { - google() - mavenCentral() - } -} - -rootProject.buildDir = file("../build") - -subprojects { - project.buildDir = file("${rootProject.buildDir}/${project.name}") -} -subprojects { - project.evaluationDependsOn(":app") - dependencyLocking { - ignoredDependencies.add("io.flutter:*") - lockFile = file("${rootProject.projectDir}/project-${project.name}.lockfile") - if (!project.hasProperty("local-engine-repo")) { - lockAllConfigurations() - } - } -} - -tasks.register("clean") { - delete(rootProject.buildDir) -} diff --git a/examples/hello_world/android/buildscript-gradle.lockfile b/examples/hello_world/android/buildscript-gradle.lockfile index 477cf7aaec3..14350adbcb4 100644 --- a/examples/hello_world/android/buildscript-gradle.lockfile +++ b/examples/hello_world/android/buildscript-gradle.lockfile @@ -1,153 +1,29 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -androidx.databinding:databinding-common:7.4.2=classpath -androidx.databinding:databinding-compiler-common:7.4.2=classpath -com.android.application:com.android.application.gradle.plugin:7.4.2=classpath -com.android.databinding:baseLibrary:7.4.2=classpath -com.android.tools.analytics-library:crash:30.4.2=classpath -com.android.tools.analytics-library:protos:30.4.2=classpath -com.android.tools.analytics-library:shared:30.4.2=classpath -com.android.tools.analytics-library:tracker:30.4.2=classpath -com.android.tools.build.jetifier:jetifier-core:1.0.0-beta10=classpath -com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta10=classpath -com.android.tools.build:aapt2-proto:7.4.2-8841542=classpath -com.android.tools.build:aaptcompiler:7.4.2=classpath -com.android.tools.build:apksig:7.4.2=classpath -com.android.tools.build:apkzlib:7.4.2=classpath -com.android.tools.build:builder-model:7.4.2=classpath -com.android.tools.build:builder-test-api:7.4.2=classpath -com.android.tools.build:builder:7.4.2=classpath -com.android.tools.build:bundletool:1.11.4=classpath -com.android.tools.build:gradle-api:7.4.2=classpath -com.android.tools.build:gradle-settings-api:7.4.2=classpath -com.android.tools.build:gradle:7.4.2=classpath -com.android.tools.build:manifest-merger:30.4.2=classpath -com.android.tools.build:transform-api:2.0.0-deprecated-use-gradle-api=classpath -com.android.tools.ddms:ddmlib:30.4.2=classpath -com.android.tools.layoutlib:layoutlib-api:30.4.2=classpath -com.android.tools.lint:lint-model:30.4.2=classpath -com.android.tools.lint:lint-typedef-remover:30.4.2=classpath -com.android.tools.utp:android-device-provider-ddmlib-proto:30.4.2=classpath -com.android.tools.utp:android-device-provider-gradle-proto:30.4.2=classpath -com.android.tools.utp:android-test-plugin-host-additional-test-output-proto:30.4.2=classpath -com.android.tools.utp:android-test-plugin-host-coverage-proto:30.4.2=classpath -com.android.tools.utp:android-test-plugin-host-retention-proto:30.4.2=classpath -com.android.tools.utp:android-test-plugin-result-listener-gradle-proto:30.4.2=classpath -com.android.tools:annotations:30.4.2=classpath -com.android.tools:common:30.4.2=classpath -com.android.tools:dvlib:30.4.2=classpath -com.android.tools:repository:30.4.2=classpath -com.android.tools:sdk-common:30.4.2=classpath -com.android.tools:sdklib:30.4.2=classpath -com.android:signflinger:7.4.2=classpath -com.android:zipflinger:7.4.2=classpath -com.github.gundy:semver4j:0.16.4=classpath -com.google.android:annotations:4.1.1.4=classpath -com.google.api.grpc:proto-google-common-protos:2.0.1=classpath -com.google.auto.value:auto-value-annotations:1.6.2=classpath -com.google.code.findbugs:jsr305:3.0.2=classpath -com.google.code.gson:gson:2.8.9=classpath -com.google.crypto.tink:tink:1.3.0-rc2=classpath -com.google.dagger:dagger:2.28.3=classpath -com.google.errorprone:error_prone_annotations:2.4.0=classpath -com.google.flatbuffers:flatbuffers-java:1.12.0=classpath -com.google.guava:failureaccess:1.0.1=classpath -com.google.guava:guava:30.1-jre=classpath -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=classpath -com.google.j2objc:j2objc-annotations:1.3=classpath -com.google.jimfs:jimfs:1.1=classpath -com.google.protobuf:protobuf-java-util:3.17.2=classpath -com.google.protobuf:protobuf-java:3.17.2=classpath -com.google.testing.platform:core-proto:0.0.8-alpha08=classpath -com.googlecode.juniversalchardet:juniversalchardet:1.0.3=classpath -com.squareup:javapoet:1.10.0=classpath -com.squareup:javawriter:2.5.0=classpath -com.sun.activation:javax.activation:1.2.0=classpath -com.sun.istack:istack-commons-runtime:3.0.8=classpath -com.sun.xml.fastinfoset:FastInfoset:1.2.16=classpath -commons-codec:commons-codec:1.11=classpath -commons-io:commons-io:2.4=classpath -commons-logging:commons-logging:1.2=classpath -de.undercouch:gradle-download-task:4.1.1=classpath -io.grpc:grpc-api:1.39.0=classpath -io.grpc:grpc-context:1.39.0=classpath -io.grpc:grpc-core:1.39.0=classpath -io.grpc:grpc-netty:1.39.0=classpath -io.grpc:grpc-protobuf-lite:1.39.0=classpath -io.grpc:grpc-protobuf:1.39.0=classpath -io.grpc:grpc-stub:1.39.0=classpath -io.netty:netty-buffer:4.1.52.Final=classpath -io.netty:netty-codec-http2:4.1.52.Final=classpath -io.netty:netty-codec-http:4.1.52.Final=classpath -io.netty:netty-codec-socks:4.1.52.Final=classpath -io.netty:netty-codec:4.1.52.Final=classpath -io.netty:netty-common:4.1.52.Final=classpath -io.netty:netty-handler-proxy:4.1.52.Final=classpath -io.netty:netty-handler:4.1.52.Final=classpath -io.netty:netty-resolver:4.1.52.Final=classpath -io.netty:netty-transport:4.1.52.Final=classpath -io.perfmark:perfmark-api:0.23.0=classpath -jakarta.activation:jakarta.activation-api:1.2.1=classpath -jakarta.xml.bind:jakarta.xml.bind-api:2.3.2=classpath -javax.annotation:javax.annotation-api:1.3.2=classpath -javax.inject:javax.inject:1=classpath -net.java.dev.jna:jna-platform:5.6.0=classpath -net.java.dev.jna:jna:5.6.0=classpath -net.sf.jopt-simple:jopt-simple:4.9=classpath -net.sf.kxml:kxml2:2.3.0=classpath -org.apache.commons:commons-compress:1.20=classpath -org.apache.httpcomponents:httpclient:4.5.13=classpath -org.apache.httpcomponents:httpcore:4.4.13=classpath -org.apache.httpcomponents:httpmime:4.5.6=classpath -org.bitbucket.b_c:jose4j:0.7.0=classpath -org.bouncycastle:bcpkix-jdk15on:1.67=classpath -org.bouncycastle:bcprov-jdk15on:1.67=classpath -org.checkerframework:checker-qual:3.5.0=classpath -org.codehaus.mojo:animal-sniffer-annotations:1.19=classpath -org.glassfish.jaxb:jaxb-runtime:2.3.2=classpath -org.glassfish.jaxb:txw2:2.3.2=classpath -org.jdom:jdom2:2.0.6=classpath org.jetbrains.intellij.deps:trove4j:1.0.20200330=classpath -org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.7.10=classpath -org.jetbrains.kotlin:kotlin-android-extensions:1.7.10=classpath -org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.7.10=classpath -org.jetbrains.kotlin:kotlin-build-common:1.7.10=classpath -org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10=classpath -org.jetbrains.kotlin:kotlin-compiler-runner:1.7.10=classpath -org.jetbrains.kotlin:kotlin-daemon-client:1.7.10=classpath -org.jetbrains.kotlin:kotlin-daemon-embeddable:1.7.10=classpath -org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.10=classpath -org.jetbrains.kotlin:kotlin-gradle-plugin-idea:1.7.10=classpath -org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.7.10=classpath -org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10=classpath -org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.7.10=classpath -org.jetbrains.kotlin:kotlin-native-utils:1.7.10=classpath -org.jetbrains.kotlin:kotlin-project-model:1.7.10=classpath -org.jetbrains.kotlin:kotlin-reflect:1.8.20=classpath -org.jetbrains.kotlin:kotlin-scripting-common:1.7.10=classpath -org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.10=classpath -org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.10=classpath -org.jetbrains.kotlin:kotlin-scripting-jvm:1.7.10=classpath -org.jetbrains.kotlin:kotlin-stdlib-common:1.8.20=classpath -org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.20=classpath -org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.20=classpath -org.jetbrains.kotlin:kotlin-stdlib:1.8.20=classpath -org.jetbrains.kotlin:kotlin-tooling-core:1.7.10=classpath -org.jetbrains.kotlin:kotlin-tooling-metadata:1.7.10=classpath -org.jetbrains.kotlin:kotlin-util-io:1.7.10=classpath -org.jetbrains.kotlin:kotlin-util-klib:1.7.10=classpath +org.jetbrains.kotlin:kotlin-android-extensions:1.9.0=classpath +org.jetbrains.kotlin:kotlin-build-tools-api:1.9.0=classpath +org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.0=classpath +org.jetbrains.kotlin:kotlin-compiler-runner:1.9.0=classpath +org.jetbrains.kotlin:kotlin-daemon-client:1.9.0=classpath +org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.0=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-annotations:1.9.0=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.9.0=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-idea-proto:1.9.0=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-idea:1.9.0=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.9.0=classpath +org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0=classpath +org.jetbrains.kotlin:kotlin-gradle-plugins-bom:1.9.0=classpath +org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.9.0=classpath +org.jetbrains.kotlin:kotlin-native-utils:1.9.0=classpath +org.jetbrains.kotlin:kotlin-project-model:1.9.0=classpath +org.jetbrains.kotlin:kotlin-scripting-common:1.9.0=classpath +org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.9.0=classpath +org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.9.0=classpath +org.jetbrains.kotlin:kotlin-scripting-jvm:1.9.0=classpath +org.jetbrains.kotlin:kotlin-tooling-core:1.9.0=classpath +org.jetbrains.kotlin:kotlin-util-io:1.9.0=classpath +org.jetbrains.kotlin:kotlin-util-klib:1.9.0=classpath org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=classpath -org.jetbrains:annotations:13.0=classpath -org.json:json:20180813=classpath -org.jvnet.staxex:stax-ex:1.8.1=classpath -org.ow2.asm:asm-analysis:9.2=classpath -org.ow2.asm:asm-commons:9.2=classpath -org.ow2.asm:asm-tree:9.2=classpath -org.ow2.asm:asm-util:9.2=classpath -org.ow2.asm:asm:9.2=classpath -org.slf4j:slf4j-api:1.7.30=classpath -org.tensorflow:tensorflow-lite-metadata:0.1.0-rc2=classpath -xerces:xercesImpl:2.12.0=classpath -xml-apis:xml-apis:1.4.01=classpath empty= diff --git a/examples/hello_world/android/settings.gradle.kts b/examples/hello_world/android/settings.gradle.kts index 894a8a5f26c..049c4c5661d 100644 --- a/examples/hello_world/android/settings.gradle.kts +++ b/examples/hello_world/android/settings.gradle.kts @@ -2,9 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Contents of this file should be generated automatically by -// dev/tools/bin/generate_gradle_lockfiles.dart, but currently are not. -// See #141540. +// Contents of this file automatically generated by dev/tools/bin/generate_gradle_lockfiles.dart. +// Do not merge changes to this file. See #140115. pluginManagement { val flutterSdkPath = run { @@ -24,17 +23,9 @@ pluginManagement { } } -buildscript { - dependencyLocking { - lockFile = file("${rootProject.projectDir}/buildscript-gradle.lockfile") - lockAllConfigurations() - } -} - plugins { id("dev.flutter.flutter-plugin-loader") version "1.0.0" id("com.android.application") version "7.4.2" apply false - id("org.jetbrains.kotlin.android") version "1.7.10" apply false } include(":app") diff --git a/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy b/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy index f7ca53567d0..b6650a19575 100644 --- a/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy +++ b/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy @@ -42,10 +42,10 @@ import org.gradle.internal.os.OperatingSystem class FlutterExtension { /** Sets the compileSdkVersion used by default in Flutter app projects. */ - public final int compileSdkVersion = 34 + final int compileSdkVersion = 34 /** Sets the minSdkVersion used by default in Flutter app projects. */ - public final int minSdkVersion = 19 + final int minSdkVersion = 19 /** * Sets the targetSdkVersion used by default in Flutter app projects. @@ -53,14 +53,14 @@ class FlutterExtension { * * See https://developer.android.com/guide/topics/manifest/uses-sdk-element. */ - public final int targetSdkVersion = 33 + final int targetSdkVersion = 33 /** * Sets the ndkVersion used by default in Flutter app projects. * Chosen as default version of the AGP version below as found in * https://developer.android.com/studio/projects/install-ndk#default-ndk-per-agp. */ - public final String ndkVersion = "23.1.7779620" + final String ndkVersion = "23.1.7779620" /** * Specifies the relative directory to the Flutter project directory. @@ -704,7 +704,7 @@ class FlutterPlugin implements Plugin { File buildGradle = new File(path, 'android' + File.separator + 'build.gradle') File buildGradleKts = new File(path, 'android' + File.separator + 'build.gradle.kts') if (buildGradle.exists() && buildGradleKts.exists()) { - project.logger.error( + logger.error( "Both build.gradle and build.gradle.kts exist, so " + "build.gradle.kts is ignored. This is likely a mistake." ) @@ -722,7 +722,7 @@ class FlutterPlugin implements Plugin { File settingsGradle = new File(project.projectDir.parentFile, "settings.gradle") File settingsGradleKts = new File(project.projectDir.parentFile, "settings.gradle.kts") if (settingsGradle.exists() && settingsGradleKts.exists()) { - project.logger.error( + logger.error( "Both settings.gradle and settings.gradle.kts exist, so " + "settings.gradle.kts is ignored. This is likely a mistake." )