Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
935d1478
Unverified
Commit
935d1478
authored
Dec 15, 2021
by
Emmanuel Garcia
Committed by
GitHub
Dec 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply the Kotlin plugin in a java project (#95225)
parent
22bd7246
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
41 additions
and
16 deletions
+41
-16
gradle_utils.dart
packages/flutter_tools/lib/src/android/gradle_utils.dart
+15
-5
create.dart
packages/flutter_tools/lib/src/commands/create.dart
+3
-0
create_base.dart
packages/flutter_tools/lib/src/commands/create_base.dart
+6
-0
project.dart
packages/flutter_tools/lib/src/project.dart
+3
-0
build.gradle.tmpl
...plates/app_shared/android-java.tmpl/app/build.gradle.tmpl
+1
-0
build.gradle.tmpl
.../templates/app_shared/android-java.tmpl/build.gradle.tmpl
+2
-2
build.gradle.tmpl
...emplates/app_shared/android-kotlin.tmpl/build.gradle.tmpl
+3
-1
gradle-wrapper.properties.tmpl
...ndroid.tmpl/gradle/wrapper/gradle-wrapper.properties.tmpl
+1
-1
build.gradle.tmpl
...r_tools/templates/module/android/gradle/build.gradle.tmpl
+1
-1
build.gradle.tmpl
...ls/templates/plugin/android-kotlin.tmpl/build.gradle.tmpl
+2
-2
template_manifest.json
packages/flutter_tools/templates/template_manifest.json
+4
-4
No files found.
packages/flutter_tools/lib/src/android/gradle_utils.dart
View file @
935d1478
...
...
@@ -19,7 +19,17 @@ import '../project.dart';
import
'../reporting/reporting.dart'
;
import
'android_sdk.dart'
;
const
String
_defaultGradleVersion
=
'6.7'
;
// These are the versions used in the project templates.
//
// In general, Flutter aims to default to the latest version.
// However, this currently requires to migrate existing integration tests to the latest supported values.
//
// For more information about the latest version, check:
// https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
// https://kotlinlang.org/docs/gradle.html#plugin-and-versions
const
String
templateDefaultGradleVersion
=
'6.7'
;
const
String
templateAndroidGradlePluginVersion
=
'4.1.0'
;
const
String
templateKotlinGradlePluginVersion
=
'1.4.32'
;
final
RegExp
_androidPluginRegExp
=
RegExp
(
r'com\.android\.tools\.build:gradle:(\d+\.\d+\.\d+)'
);
...
...
@@ -109,14 +119,14 @@ distributionUrl=https\\://services.gradle.org/distributions/gradle-$gradleVersio
String
getGradleVersionForAndroidPlugin
(
Directory
directory
,
Logger
logger
)
{
final
File
buildFile
=
directory
.
childFile
(
'build.gradle'
);
if
(!
buildFile
.
existsSync
())
{
logger
.
printTrace
(
"
$buildFile
doesn't exist, assuming
AGP version:
$_d
efaultGradleVersion
"
);
return
_d
efaultGradleVersion
;
logger
.
printTrace
(
"
$buildFile
doesn't exist, assuming
Gradle version:
$templateD
efaultGradleVersion
"
);
return
templateD
efaultGradleVersion
;
}
final
String
buildFileContent
=
buildFile
.
readAsStringSync
();
final
Iterable
<
Match
>
pluginMatches
=
_androidPluginRegExp
.
allMatches
(
buildFileContent
);
if
(
pluginMatches
.
isEmpty
)
{
logger
.
printTrace
(
"
$buildFile
doesn't provide an AGP version, assuming
AGP version:
$_d
efaultGradleVersion
"
);
return
_d
efaultGradleVersion
;
logger
.
printTrace
(
"
$buildFile
doesn't provide an AGP version, assuming
Gradle version:
$templateD
efaultGradleVersion
"
);
return
templateD
efaultGradleVersion
;
}
final
String
?
androidPluginVersion
=
pluginMatches
.
first
.
group
(
1
);
logger
.
printTrace
(
'
$buildFile
provides AGP version:
$androidPluginVersion
'
);
...
...
packages/flutter_tools/lib/src/commands/create.dart
View file @
935d1478
...
...
@@ -271,6 +271,9 @@ class CreateCommand extends CreateBase {
// Enable null safety everywhere.
dartSdkVersionBounds:
'">=
$dartSdk
<3.0.0"'
,
implementationTests:
boolArg
(
'implementation-tests'
),
agpVersion:
gradle
.
templateAndroidGradlePluginVersion
,
kotlinVersion:
gradle
.
templateKotlinGradlePluginVersion
,
gradleVersion:
gradle
.
templateDefaultGradleVersion
,
);
final
String
relativeDirPath
=
globals
.
fs
.
path
.
relative
(
projectDirPath
);
...
...
packages/flutter_tools/lib/src/commands/create_base.dart
View file @
935d1478
...
...
@@ -336,6 +336,9 @@ abstract class CreateBase extends FlutterCommand {
String
iosLanguage
,
String
flutterRoot
,
String
dartSdkVersionBounds
,
String
agpVersion
,
String
kotlinVersion
,
String
gradleVersion
,
bool
withPluginHook
=
false
,
bool
ios
=
false
,
bool
android
=
false
,
...
...
@@ -398,6 +401,9 @@ abstract class CreateBase extends FlutterCommand {
'year'
:
DateTime
.
now
().
year
,
'dartSdkVersionBounds'
:
dartSdkVersionBounds
,
'implementationTests'
:
implementationTests
,
'agpVersion'
:
agpVersion
,
'kotlinVersion'
:
kotlinVersion
,
'gradleVersion'
:
gradleVersion
,
};
}
...
...
packages/flutter_tools/lib/src/project.dart
View file @
935d1478
...
...
@@ -543,6 +543,9 @@ class AndroidProject extends FlutterProjectPlatform {
'projectName'
:
parent
.
manifest
.
appName
,
'androidIdentifier'
:
androidIdentifier
,
'androidX'
:
usesAndroidX
,
'agpVersion'
:
gradle
.
templateAndroidGradlePluginVersion
,
'kotlinVersion'
:
gradle
.
templateKotlinGradlePluginVersion
,
'gradleVersion'
:
gradle
.
templateDefaultGradleVersion
,
},
printStatusWhenWriting:
false
,
);
...
...
packages/flutter_tools/templates/app_shared/android-java.tmpl/app/build.gradle.tmpl
View file @
935d1478
...
...
@@ -22,6 +22,7 @@ if (flutterVersionName == null) {
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
...
...
packages/flutter_tools/templates/app_shared/android-
kotlin.tmpl/build.gradle
→
packages/flutter_tools/templates/app_shared/android-
java.tmpl/build.gradle.tmpl
View file @
935d1478
buildscript {
ext
.
kotlin_version
=
'
1.4.32
'
ext.kotlin_version = '
{{kotlinVersion}}
'
repositories {
google()
mavenCentral()
}
dependencies {
classpath
'com.android.tools.build:gradle:
4.1.0
'
classpath 'com.android.tools.build:gradle:
{{agpVersion}}
'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
...
...
packages/flutter_tools/templates/app_shared/android-
java.tmpl/build.gradle
→
packages/flutter_tools/templates/app_shared/android-
kotlin.tmpl/build.gradle.tmpl
View file @
935d1478
buildscript {
ext.kotlin_version = '{{kotlinVersion}}'
repositories {
google()
mavenCentral()
}
dependencies {
classpath
'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
...
...
packages/flutter_tools/templates/app_shared/android.tmpl/gradle/wrapper/gradle-wrapper.properties
→
packages/flutter_tools/templates/app_shared/android.tmpl/gradle/wrapper/gradle-wrapper.properties
.tmpl
View file @
935d1478
...
...
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-
6.7
-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-
{{gradleVersion}}
-all.zip
packages/flutter_tools/templates/module/android/gradle/build.gradle.
copy.
tmpl
→
packages/flutter_tools/templates/module/android/gradle/build.gradle.tmpl
View file @
935d1478
...
...
@@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:
4.1.0
'
classpath 'com.android.tools.build:gradle:
{{agpVersion}}
'
}
}
...
...
packages/flutter_tools/templates/plugin/android-kotlin.tmpl/build.gradle.tmpl
View file @
935d1478
...
...
@@ -2,14 +2,14 @@ group '{{androidIdentifier}}'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '
1.4.32
'
ext.kotlin_version = '
{{kotlinVersion}}
'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:
4.1.0
'
classpath 'com.android.tools.build:gradle:
{{agpVersion}}
'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
...
...
packages/flutter_tools/templates/template_manifest.json
View file @
935d1478
...
...
@@ -18,11 +18,11 @@
"templates/app_shared/analysis_options.yaml.tmpl"
,
"templates/app_shared/android-java.tmpl/app/build.gradle.tmpl"
,
"templates/app_shared/android-java.tmpl/app/src/main/java/androidIdentifier/MainActivity.java.tmpl"
,
"templates/app_shared/android-java.tmpl/build.gradle"
,
"templates/app_shared/android-java.tmpl/build.gradle
.tmpl
"
,
"templates/app_shared/android-java.tmpl/projectName_android.iml.tmpl"
,
"templates/app_shared/android-kotlin.tmpl/app/build.gradle.tmpl"
,
"templates/app_shared/android-kotlin.tmpl/app/src/main/kotlin/androidIdentifier/MainActivity.kt.tmpl"
,
"templates/app_shared/android-kotlin.tmpl/build.gradle"
,
"templates/app_shared/android-kotlin.tmpl/build.gradle
.tmpl
"
,
"templates/app_shared/android-kotlin.tmpl/projectName_android.iml.tmpl"
,
"templates/app_shared/android.tmpl/.gitignore"
,
"templates/app_shared/android.tmpl/app/src/debug/AndroidManifest.xml.tmpl"
,
...
...
@@ -38,7 +38,7 @@
"templates/app_shared/android.tmpl/app/src/main/res/values/styles.xml"
,
"templates/app_shared/android.tmpl/app/src/profile/AndroidManifest.xml.tmpl"
,
"templates/app_shared/android.tmpl/gradle.properties.tmpl"
,
"templates/app_shared/android.tmpl/gradle/wrapper/gradle-wrapper.properties"
,
"templates/app_shared/android.tmpl/gradle/wrapper/gradle-wrapper.properties
.tmpl
"
,
"templates/app_shared/android.tmpl/settings.gradle"
,
"templates/app_shared/ios-objc.tmpl/Runner.xcodeproj/project.pbxproj.tmpl"
,
"templates/app_shared/ios-objc.tmpl/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme"
,
...
...
@@ -207,7 +207,7 @@
"templates/module/android/deferred_component/build.gradle.tmpl"
,
"templates/module/android/deferred_component/src/main/AndroidManifest.xml.tmpl"
,
"templates/module/android/gradle/build.gradle.
copy.
tmpl"
,
"templates/module/android/gradle/build.gradle.tmpl"
,
"templates/module/android/gradle/gradle.properties.tmpl"
,
"templates/module/android/host_app_common/app.tmpl/build.gradle.tmpl"
,
"templates/module/android/host_app_common/app.tmpl/src/main/AndroidManifest.xml.tmpl"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment