From d0556f02c41e9047d0f0872ee8ad2f2d9c45e5fc Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Sun, 26 Sep 2021 16:56:18 +0200 Subject: [PATCH 1/4] fix: update plugin gradle script --- vendor/gradle-plugin/build.gradle | 44 ++++++++++++++++++------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/vendor/gradle-plugin/build.gradle b/vendor/gradle-plugin/build.gradle index 657e49bb60..8fe646d730 100644 --- a/vendor/gradle-plugin/build.gradle +++ b/vendor/gradle-plugin/build.gradle @@ -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 } +def computeTargetSdkVersion = { -> project.hasProperty("targetSdk") ? targetSdk : 28 as int } +def computeBuildToolsVersion = { -> + project.hasProperty("buildToolsVersion") ? buildToolsVersion : "28.0.3" as String +} buildscript { def computeKotlinVersion = { -> project.hasProperty("kotlinVersion") ? kotlinVersion : "1.4.21" } @@ -88,39 +94,41 @@ allprojects { } -def computeCompileSdkVersion = { -> project.hasProperty("compileSdk") ? compileSdk : 28 } -def computeBuildToolsVersion = { -> - project.hasProperty("buildToolsVersion") ? buildToolsVersion : "28.0.3" -} - android { + kotlinOptions { + jvmTarget = '1.8' + } applyBeforePluginGradleConfiguration() compileSdkVersion computeCompileSdkVersion() buildToolsVersion computeBuildToolsVersion() + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + defaultConfig { - targetSdkVersion 26 + targetSdkVersion computeTargetSdkVersion() versionCode 1 versionName "1.0" } } dependencies { - def supportVer = "28.0.0" - if (project.hasProperty("supportVersion")) { - supportVer = supportVersion + def androidXAppCompatVersion = "1.3.1" + if (project.hasProperty("androidXAppCompat")) { + androidXAppCompatVersion = androidXAppCompat } - 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 = "2.0.1" + if (project.hasProperty("androidXMultidex")) { + androidXMultidexVersion = androidXMultidex } + def kotlinVersion = computeKotlinVersion() + implementation "androidx.multidex:multidex:$androidXMultidexVersion" + implementation "androidx.appcompat:appcompat:$androidXAppCompatVersion" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" } def applyBeforePluginGradleConfiguration() { From 3c716f70152c608ea22e2d2e75b57df73fa1276e Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Sun, 3 Oct 2021 15:00:41 +0200 Subject: [PATCH 2/4] chore: refactoring --- vendor/gradle-plugin/build.gradle | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/vendor/gradle-plugin/build.gradle b/vendor/gradle-plugin/build.gradle index 8fe646d730..51007604e7 100644 --- a/vendor/gradle-plugin/build.gradle +++ b/vendor/gradle-plugin/build.gradle @@ -116,17 +116,12 @@ android { } dependencies { - def androidXAppCompatVersion = "1.3.1" - if (project.hasProperty("androidXAppCompat")) { - androidXAppCompatVersion = androidXAppCompat - } - - def androidXMultidexVersion = "2.0.1" - if (project.hasProperty("androidXMultidex")) { - androidXMultidexVersion = androidXMultidex - } + def androidXMultidexVersion = project.hasProperty("androidXMultidexVersion") ? project.androidXMultidexVersion : "2.0.1" + def androidxVersion = project.hasProperty("androidxVersion") ? project.androidxVersion : "1.2.0" + def androidXAppCompatVersion = project.hasProperty("androidXAppCompat") ? project.androidXAppCompat : "1.3.1" 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" } From 40b5eb883272d9e810e8d2377d7915c0976a3597 Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Sun, 3 Oct 2021 15:00:56 +0200 Subject: [PATCH 3/4] fix: makes libs smaller and build faster see https://www.mobileit.cz/Blog/Pages/r-class.aspx --- vendor/gradle-plugin/gradle.properties | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vendor/gradle-plugin/gradle.properties b/vendor/gradle-plugin/gradle.properties index 4385ddd9f4..e05b2d8909 100644 --- a/vendor/gradle-plugin/gradle.properties +++ b/vendor/gradle-plugin/gradle.properties @@ -18,3 +18,6 @@ org.gradle.jvmargs=-Xmx16384M android.enableJetifier=true android.useAndroidX=true +android.nonTransitiveRClass=true +android.namespacedRClass=true +android.enableSeparateRClassCompilation=true From c4970e5d586f068a0a83f4910dbbee18127e1f65 Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Sun, 3 Oct 2021 21:52:43 +0200 Subject: [PATCH 4/4] fix: remove unneeded R.class and BuildConfig.class for plugins can still be enabled with `generateBuildConfig` and `generateR` --- vendor/gradle-plugin/build.gradle | 23 ++++++++++++++++++++++- vendor/gradle-plugin/gradle.properties | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/vendor/gradle-plugin/build.gradle b/vendor/gradle-plugin/build.gradle index 51007604e7..626dfca794 100644 --- a/vendor/gradle-plugin/build.gradle +++ b/vendor/gradle-plugin/build.gradle @@ -134,4 +134,25 @@ def applyBeforePluginGradleConfiguration() { outLogger.withStyle(Style.SuccessHeader).println "\t ~ applying user-defined configuration from ${beforePluginGradle}" apply from: pathToBeforePluginGradle } -} \ No newline at end of file +} + +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' + } + } +}) \ No newline at end of file diff --git a/vendor/gradle-plugin/gradle.properties b/vendor/gradle-plugin/gradle.properties index e05b2d8909..849c4366ef 100644 --- a/vendor/gradle-plugin/gradle.properties +++ b/vendor/gradle-plugin/gradle.properties @@ -20,4 +20,4 @@ android.enableJetifier=true android.useAndroidX=true android.nonTransitiveRClass=true android.namespacedRClass=true -android.enableSeparateRClassCompilation=true +android.enableSeparateRClassCompilation=true \ No newline at end of file