-
-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: update plugin gradle script #5578
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,12 @@ apply plugin: 'com.android.library' | |
apply plugin: 'kotlin-android' | ||
apply plugin: 'kotlin-android-extensions' | ||
|
||
def computeKotlinVersion = { -> project.hasProperty("kotlinVersion") ? kotlinVersion : "1.4.21" } | ||
def computeCompileSdkVersion = { -> project.hasProperty("compileSdk") ? compileSdk : 28 as int } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we change the default |
||
def computeTargetSdkVersion = { -> project.hasProperty("targetSdk") ? targetSdk : 28 as int } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we change |
||
def computeBuildToolsVersion = { -> | ||
project.hasProperty("buildToolsVersion") ? buildToolsVersion : "28.0.3" as String | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With 8.2 - should we default to build tools 32? |
||
} | ||
|
||
buildscript { | ||
def computeKotlinVersion = { -> project.hasProperty("kotlinVersion") ? kotlinVersion : "1.4.21" } | ||
|
@@ -88,39 +94,36 @@ allprojects { | |
} | ||
|
||
|
||
def computeCompileSdkVersion = { -> project.hasProperty("compileSdk") ? compileSdk : 28 } | ||
def computeBuildToolsVersion = { -> | ||
project.hasProperty("buildToolsVersion") ? buildToolsVersion : "28.0.3" | ||
} | ||
|
||
android { | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to set the target to 1.8 with gradle7+? Officially recommended jdk is 11, so this might need to match that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should be able to use more but was not tested https://kotlinlang.org/docs/faq.html#which-versions-of-jvm-does-kotlin-target |
||
} | ||
applyBeforePluginGradleConfiguration() | ||
|
||
compileSdkVersion computeCompileSdkVersion() | ||
buildToolsVersion computeBuildToolsVersion() | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
Comment on lines
+107
to
+108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question as |
||
} | ||
|
||
defaultConfig { | ||
targetSdkVersion 26 | ||
targetSdkVersion computeTargetSdkVersion() | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
} | ||
|
||
dependencies { | ||
def supportVer = "28.0.0" | ||
if (project.hasProperty("supportVersion")) { | ||
supportVer = supportVersion | ||
} | ||
compileOnly "com.android.support:support-v4:$supportVer" | ||
compileOnly "com.android.support:appcompat-v7:$supportVer" | ||
|
||
configurations.all { | ||
resolutionStrategy.eachDependency { DependencyResolveDetails details -> | ||
if (details.requested.group == "com.android.support" && !details.requested.name.startsWith("multidex")) { | ||
details.useVersion supportVer | ||
} | ||
} | ||
} | ||
def androidXMultidexVersion = project.hasProperty("androidXMultidexVersion") ? project.androidXMultidexVersion : "2.0.1" | ||
def androidxVersion = project.hasProperty("androidxVersion") ? project.androidxVersion : "1.2.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use 1.7.0? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure about 1.7.0. Maybe 1.6.0 |
||
def androidXAppCompatVersion = project.hasProperty("androidXAppCompat") ? project.androidXAppCompat : "1.3.1" | ||
farfromrefug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def kotlinVersion = computeKotlinVersion() | ||
implementation "androidx.multidex:multidex:$androidXMultidexVersion" | ||
implementation "androidx.core:core:$androidxVersion" | ||
implementation "androidx.appcompat:appcompat:$androidXAppCompatVersion" | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" | ||
} | ||
|
||
def applyBeforePluginGradleConfiguration() { | ||
|
@@ -131,4 +134,25 @@ def applyBeforePluginGradleConfiguration() { | |
outLogger.withStyle(Style.SuccessHeader).println "\t ~ applying user-defined configuration from ${beforePluginGradle}" | ||
apply from: pathToBeforePluginGradle | ||
} | ||
} | ||
} | ||
|
||
afterEvaluate { | ||
def generateBuildConfig = project.hasProperty("generateBuildConfig") ? project.generateBuildConfig : false | ||
def generateR = project.hasProperty("generateR") ? project.generateR : false | ||
generateReleaseBuildConfig.enabled = generateBuildConfig | ||
generateDebugBuildConfig.enabled = generateBuildConfig | ||
generateReleaseResValues.enabled = generateR | ||
generateDebugResValues.enabled = generateR | ||
} | ||
tasks.whenTaskAdded({ DefaultTask currentTask -> | ||
if (currentTask.name == 'bundleRelease' || currentTask.name == 'bundleDebug') { | ||
def generateBuildConfig = project.hasProperty("generateBuildConfig") ? project.generateBuildConfig : false | ||
def generateR = project.hasProperty("generateR") ? project.generateR : false | ||
if (!generateBuildConfig) { | ||
currentTask.exclude '**/BuildConfig.class' | ||
} | ||
if (!generateR) { | ||
currentTask.exclude '**/R.class', '**/R$*.class' | ||
} | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we bump kotlinVersion without too much testing, or is 1.4.21 safer for now?