From d8521806113bd5d0f1b8592ddd84ed19a49a90f7 Mon Sep 17 00:00:00 2001 From: Khalid Hamid Date: Sat, 3 Sep 2022 23:16:51 +0800 Subject: [PATCH] Chore: added sonar properties file --- .../Fix__refactored_plugin_utils.patch | 1053 ----------------- GitHubRepos/sonar-project.properties | 11 + 2 files changed, 11 insertions(+), 1053 deletions(-) delete mode 100644 GitHubRepos/Fix__refactored_plugin_utils.patch create mode 100644 GitHubRepos/sonar-project.properties diff --git a/GitHubRepos/Fix__refactored_plugin_utils.patch b/GitHubRepos/Fix__refactored_plugin_utils.patch deleted file mode 100644 index b7a364a7..00000000 --- a/GitHubRepos/Fix__refactored_plugin_utils.patch +++ /dev/null @@ -1,1053 +0,0 @@ -Index: GitHubRepos/.gitignore -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>UTF-8 -=================================================================== -diff --git a/GitHubRepos/.gitignore b/GitHubRepos/.gitignore ---- a/GitHubRepos/.gitignore (revision ff4b928fab91e8dc01ee44c5260d053e4af858cb) -+++ b/GitHubRepos/.gitignore (revision 8364b20725d554ae538e6217c06ffe75004867c2) -@@ -14,3 +14,4 @@ - .cxx - .DG_Store - /buildSrc/build/ -+/.idea/shelf/ -Index: GitHubRepos/app/build.gradle.kts -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>UTF-8 -=================================================================== -diff --git a/GitHubRepos/app/build.gradle.kts b/GitHubRepos/app/build.gradle.kts ---- a/GitHubRepos/app/build.gradle.kts (revision ff4b928fab91e8dc01ee44c5260d053e4af858cb) -+++ b/GitHubRepos/app/build.gradle.kts (revision 8364b20725d554ae538e6217c06ffe75004867c2) -@@ -23,14 +23,6 @@ - } - } - --spotless { -- kotlin { -- target ("**/*.kt") -- ktlint("0.44.0").userData(mapOf("disabled_rules" to "no-wildcard-imports")) -- licenseHeaderFile(project.rootProject.file("scripts/copyright.kt")) -- } --} -- - allOpen.annotation("com.khalid.hamid.githubrepos.testing.OpenClass") - android { - pln("android block...") -Index: GitHubRepos/buildSrc/build.gradle.kts -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>UTF-8 -=================================================================== -diff --git a/GitHubRepos/buildSrc/build.gradle.kts b/GitHubRepos/buildSrc/build.gradle.kts ---- a/GitHubRepos/buildSrc/build.gradle.kts (revision ff4b928fab91e8dc01ee44c5260d053e4af858cb) -+++ b/GitHubRepos/buildSrc/build.gradle.kts (revision 8364b20725d554ae538e6217c06ffe75004867c2) -@@ -1,3 +1,4 @@ -+ - plugins { - `java-gradle-plugin` - `kotlin-dsl` -@@ -16,6 +17,8 @@ - const val KOTLIN = "1.6.10" - } - -+ -+ - dependencies { - implementation("com.google.devtools.ksp:symbol-processing-api:1.6.10-1.0.4") - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${GlobalVersions.KOTLIN}") -Index: GitHubRepos/buildSrc/src/main/java/com/dependencies/KPluginExtensions.kt -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>UTF-8 -=================================================================== -diff --git a/GitHubRepos/buildSrc/src/main/java/com/dependencies/KPluginExtensions.kt b/GitHubRepos/buildSrc/src/main/java/com/dependencies/KPluginExtensions.kt ---- a/GitHubRepos/buildSrc/src/main/java/com/dependencies/KPluginExtensions.kt (revision ff4b928fab91e8dc01ee44c5260d053e4af858cb) -+++ b/GitHubRepos/buildSrc/src/main/java/com/dependencies/KPluginExtensions.kt (revision 8364b20725d554ae538e6217c06ffe75004867c2) -@@ -17,6 +17,11 @@ - var lintBaseLineFilePath = "" - var lintExclusionRules : List = emptyList() - var checkstylePath = "" -+ /** -+ * provide class path to your all open annotation in your source code -+ * Ex: com.khalid.hamid.githubrepos.testing.OpenClass -+ */ -+ var openAnnotationPath = "com.khalid.hamid.githubrepos.testing.OpenClass" - - - open val jacoco: JacocoOptions = JacocoOptions() -@@ -27,7 +32,6 @@ - - open class JacocoOptions { - open var isEnabled: Boolean = true -- - open var excludes: ArrayList = arrayListOf() - open var dependentTasklist: ArrayList = arrayListOf() - open fun excludes(vararg excludes: String) { -Index: GitHubRepos/buildSrc/src/main/java/com/dependencies/KhalidAndroidPlugin.kt -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>UTF-8 -=================================================================== -diff --git a/GitHubRepos/buildSrc/src/main/java/com/dependencies/KhalidAndroidPlugin.kt b/GitHubRepos/buildSrc/src/main/java/com/dependencies/KhalidAndroidPlugin.kt ---- a/GitHubRepos/buildSrc/src/main/java/com/dependencies/KhalidAndroidPlugin.kt (revision ff4b928fab91e8dc01ee44c5260d053e4af858cb) -+++ b/GitHubRepos/buildSrc/src/main/java/com/dependencies/KhalidAndroidPlugin.kt (revision 8364b20725d554ae538e6217c06ffe75004867c2) -@@ -25,60 +25,58 @@ - import org.gradle.testing.jacoco.plugins.JacocoPlugin - import org.jetbrains.kotlin.gradle.plugin.KaptExtension - --open class KhalidAndroidPlugin : Plugin, Utility() { -+open class KhalidAndroidPlugin : Plugin { -+ -+ lateinit var ext: KPluginExtensions -+ -+ - /** - * Determines if a Project is the 'library' module - */ - val Project.isLibrary get() = name == "app" - private val Project.configDir get() = "$rootDir/quality" -- private var lintExclusionRules = arrayListOf("ObsoleteLintCustomCheck", // ButterKnife will fix this in v9.0 -- "IconExpectedSize", -- "InvalidPackage", // Firestore uses GRPC which makes lint mad -- "NewerVersionAvailable", "GradleDependency", // For reproducible builds -- "SelectableText", "SyntheticAccessor") - - override fun apply(target: Project) { -- ext = target.extensions.create("KPlugin") -- target.applyPlugins((target.name == "app")) -+ if(target.properties.entries.contains("enableBuildLogs")){ -+ PluginConstants.enableBuildLogs = true -+ } else { -+ println("========================================================================") -+ println("add enableBuildLogs=true in gradle.properties to print plugin build logs") -+ println("========================================================================") -+ } -+ ext = target.extensions.create("KPlugin") -+ applyPlugins((target.name == "app"), target) - pln("name "+ target.name) -- //TODO: unable to use extension property in apply function -- target.configureAndroid() -- target.configureQuality() -+ configureAndroid(target) -+ configureQuality(target) -+ configureSpotless(target) - pln("ext ..after "+ ext.compileSDK) -- target.afterEvaluate { -- pln("afterEvaluate") -- target.extensions.getByType(KPluginExtensions::class.java).run { -- val jacocoOptions = this.jacoco -- if (jacocoOptions.isEnabled) { -- // Setup jacoco tasks to generate coverage report for this module. -- target.plugins.apply(JacocoPlugin::class.java) -- target.plugins.all { -- when (this) { -- is LibraryPlugin -> { -- target.extensions.getByType(LibraryExtension::class.java).run { -- configureJacoco(target, libraryVariants, jacocoOptions) -- } -- } -- is AppPlugin -> { -- target.extensions.getByType(AppExtension::class.java).run { -- configureJacoco(target, applicationVariants, jacocoOptions) -- } -- } -- } -- } -- } -+ } -+ -+ private fun configureAllOpen(project: Project) = project.run { -+ try { -+ if(ext.openAnnotationPath.isEmpty()){ -+ throw java.lang.IllegalStateException(" missing openAnnotationPath value") - } -+ val allOpenExt = extensions.getByName("allOpen") as org.jetbrains.kotlin.allopen.gradle.AllOpenExtension -+ allOpenExt.annotation("com.khalid.hamid.githubrepos.testing.OpenClass") -+ }catch (e: Exception){ -+ e.printStackTrace() - } - } - -- fun Project.configureKotlin(){ -+ private fun configureKotlin(project: Project) = project.run { - configure { - configureKapt() - } - } - -- private fun Project.configureAndroid() { -- configureKotlin() -+ private fun configureAndroid(project: Project) { -+ configureKotlin(project) -+ configureAndroidDefaults(project) -+ } -+ -+ private fun configureAndroidDefaults(project: Project) = project.run { - configure{ - pln(" compileSDK "+ ext.compileSDK) - compileSdkVersion(ext.compileSDK.toInt()) -@@ -95,10 +93,8 @@ - targetSdk = ext.targetSDK.toInt() - versionName = ext.versionName - versionCode = ext.versionCode -- //TODO: dataBinding.isEnabledForTests = true - vectorDrawables.useSupportLibrary = true - testInstrumentationRunner = ext.testRunner -- - val schemas = "${projectDir}/schemas" - javaCompileOptions { - annotationProcessorOptions { -@@ -110,15 +106,12 @@ - } - } - } -- - dataBinding.enable = true - dataBinding.enableForTests = true - dataBinding.addKtx = true -- - buildFeatures.viewBinding = true -- - lintOptions { -- baselineFile = getLintBaseline() -+ baselineFile = getLintBaseline(project, ext) - isCheckAllWarnings = true - isWarningsAsErrors = true - isAbortOnError = false // TODO: fix lint issues -@@ -161,15 +154,43 @@ - UITest() - } - } -+ -+ } -+ -+ private fun configureQuality(target: Project) = target.run { -+ val project = this -+ configureCheckStyle(target) -+ // set jacoco config -+ afterEvaluate { -+ pln("afterEvaluate") -+ extensions.getByType(KPluginExtensions::class.java).run { -+ val jacocoOptions = this.jacoco -+ if (jacocoOptions.isEnabled) { -+ // Setup jacoco tasks to generate coverage report for this module. -+ plugins.apply(JacocoPlugin::class.java) -+ plugins.all { -+ when (this) { -+ is LibraryPlugin -> { -+ extensions.getByType(LibraryExtension::class.java).run { -+ configureJacoco(project, libraryVariants, jacocoOptions) -+ } -+ } -+ is AppPlugin -> { -+ extensions.getByType(AppExtension::class.java).run { -+ configureJacoco(project, applicationVariants, jacocoOptions) -+ } -+ } -+ } -+ } -+ } -+ } -+ } - } - -- // TODO: add checkstyle -- private fun Project.configureQuality() { -+ private fun configureCheckStyle(target: Project) = target.run { - apply(plugin = "checkstyle") -- - configure { toolVersion = "8.10.1" } - tasks.named("check").configure { dependsOn("checkstyle") } -- - tasks.register("checkstyle") { - var path = ext.checkstylePath - if(path.isEmpty()){ -@@ -182,11 +203,4 @@ - classpath = files() - } - } -- -- // TODO: publish plugin -- internal fun Project.configurePlugins() { -- plugins.apply("com.android.library") -- plugins.apply("org.gradle.maven-publish") // or anything else, that you would like to load -- } -- - } -\ No newline at end of file -Index: GitHubRepos/buildSrc/src/main/java/com/dependencies/PluginExt.kt -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>UTF-8 -=================================================================== -diff --git a/GitHubRepos/buildSrc/src/main/java/com/dependencies/PluginExt.kt b/GitHubRepos/buildSrc/src/main/java/com/dependencies/PluginExt.kt -new file mode 100644 ---- /dev/null (revision 8364b20725d554ae538e6217c06ffe75004867c2) -+++ b/GitHubRepos/buildSrc/src/main/java/com/dependencies/PluginExt.kt (revision 8364b20725d554ae538e6217c06ffe75004867c2) -@@ -0,0 +1,359 @@ -+package com.dependencies -+ -+import com.android.build.gradle.api.BaseVariant -+import com.diffplug.gradle.spotless.SpotlessExtension -+import org.gradle.api.Action -+import org.gradle.api.DomainObjectSet -+import org.gradle.api.Project -+import org.gradle.api.artifacts.Dependency -+import org.gradle.api.artifacts.ExternalModuleDependency -+import org.gradle.api.artifacts.dsl.DependencyHandler -+import org.gradle.kotlin.dsl.* -+import org.gradle.kotlin.dsl.accessors.runtime.addDependencyTo -+import org.gradle.testing.jacoco.tasks.JacocoReport -+import org.jetbrains.kotlin.gradle.plugin.KaptExtension -+import java.io.File -+ -+/** -+ * @author Mohammed Khalid Hamid -+ * This file has handy inline, inline extension function and constants used in this plugin -+ */ -+ -+object PluginConstants { -+ const val implementation = "implementation" -+ const val kapt = "kapt" -+ const val kaptTest = "kaptTest" -+ const val kaptAndroidTest = "kaptAndroidTest" -+ const val api = "api" -+ const val compileOnly = "compileOnly" -+ const val testImplementation = "testImplementation" -+ const val androidTestImplementation = "androidTestImplementation" -+ val lintExclusion = mutableListOf("ObsoleteLintCustomCheck", // ButterKnife will fix this in v9.0 -+ "IconExpectedSize", -+ "InvalidPackage", // Firestore uses GRPC which makes lint mad -+ "NewerVersionAvailable", "GradleDependency", // For reproducible builds -+ "SelectableText", "SyntheticAccessor") -+ -+ var enableBuildLogs = false -+} -+ -+inline fun applyPlugins(isApp : Boolean, project: Project) = project.run { -+ if(isApp){ -+ apply(plugin = "com.android.application") -+ // TODO: add in demo : apply(plugin = "com.google.gms.google-services") -+ } else { -+ apply(plugin = "com.android.library") -+ apply(plugin = "org.gradle.maven-publish") -+ } -+ apply(plugin = "kotlin-android") -+ //apply(plugin = "com.google.devtools.ksp") -+ apply(plugin = "kotlin-kapt") -+ apply(plugin = "org.jetbrains.kotlin.plugin.allopen") -+ apply(plugin = "androidx.navigation.safeargs.kotlin") -+ apply(plugin = "com.diffplug.spotless") -+ apply(plugin = "org.owasp.dependencycheck") -+ if(isApp){ -+ apply(plugin = "dagger.hilt.android.plugin") -+ } -+} -+ -+inline fun getLintBaseline(project: Project, ext: KPluginExtensions) : File = project.run { -+ val defaultLintFile = file("$rootDir/quality/lint-baseline.xml") -+ val lintBaseLineFilePath = ext.lintBaseLineFilePath -+ if(lintBaseLineFilePath.isEmpty()) return defaultLintFile -+ return file(lintBaseLineFilePath) -+} -+ -+inline fun configureSpotless(project: Project) = project.run { -+ configure{ -+ kotlin { -+ target ("**/*.kt") -+ ktlint("0.44.0").userData(mapOf("disabled_rules" to "no-wildcard-imports")) -+ licenseHeaderFile(project.rootProject.file("scripts/copyright.kt")) -+ } -+ } -+} -+ -+ -+/** -+ * ======================================================================================== -+ * common deps extension functions start -+ * ======================================================================================== -+ */ -+inline fun DependencyHandler.unitTest() { -+ testImplementation(Dependencies.JUNIT) -+ testImplementation(Dependencies.JUNIT_EXT) -+ testImplementation(Dependencies.MOCKWEBSERVER) -+ testImplementation(Dependencies.ARCH_CORE_TESTING) -+ testImplementation(Dependencies.ESPRESSO_CORE) -+ testImplementation(Dependencies.ESP_CONTRIBUTE) -+ testImplementation(Dependencies.ESP_INTENTS) -+ testImplementation(Dependencies.TEST_KTX_CORE) -+ testImplementation(Dependencies.TEST_KTX_JUNIT) -+ testImplementation(Dependencies.TEST_RULES) -+ testImplementation(Dependencies.MOKITO_CORE) -+ testImplementation(Dependencies.MOKITO_ALL) -+ testImplementation(Dependencies.MOKITO_INLINE) -+ testImplementation(Dependencies.CR_TEST) -+ testImplementation(Dependencies.MULTIDEXTEST) -+ testImplementation(Dependencies.KLUENT) -+ testImplementation(Dependencies.MOCKK) -+ testImplementation(Dependencies.CR_TEST_DEBUG) -+ testImplementation(Dependencies.CR_TEST) -+ -+ //TODO: check if you need JDK9 deps. JDK9() -+} -+ -+inline fun DependencyHandler.JDK9(){ -+ compileOnly(Dependencies.jdk9Deps) -+ kapt(Dependencies.jaxbApi) -+ kapt(Dependencies.jaxbCore) -+ kapt(Dependencies.jaxbImpl) -+} -+ -+/** -+ * 1. KOTLIN -+ * 2. V7 -+ * 3. CONSTRAINT LAYOUT -+ * 4. TIMBER -+ * 5. RETROFIT ADAPTER -+ * 6. RETROFIT GSON CONVERTER -+ * 7. RETROFIT RUNTIME -+ * 8. OKHTTP -+ * 9. OKHTTP INTERCEPTOR -+ * 10. CARD VIEW -+ * 11. GOOGLE MATERIAL -+ * 12. ANNOTATIONS -+ * -+ */ -+inline fun DependencyHandler.commonAndroidLibs(){ -+ implementation(Dependencies.KOTLIN) -+ implementation(Dependencies.V7) -+ implementation(Dependencies.CONSTRAINT_LAYOUT) -+ implementation(Dependencies.TIMBER) -+ implementation(Dependencies.SWIPEX) -+ implementation(Dependencies.MULTIDEX) -+ -+ implementation(Dependencies.RETROFIT_ADAPTER) -+ implementation(Dependencies.RETROFIT_GSON_CONVERTER) -+ implementation(Dependencies.RETROFIT_RUNTIME) -+ -+ implementation(Dependencies.OKHTTP) -+ implementation(Dependencies.OKHTTP_INTERCEPTOR) -+ -+ implementation(Dependencies.CARD_VIEW) -+ implementation(Dependencies.GOOGLE_MATERIAL) -+ implementation(Dependencies.ANNOTATIONS) -+} -+ -+ -+@Suppress("UNUSED_PARAMETER") -+inline fun DependencyHandler.dagger(){ -+ //implementation(Dependencies.DAGGER_RUNTIME) -+ api(Dependencies.DAGGER_ANDROID) -+ //implementation(Dependencies.DAGGER_ANDROID_SUPPORT) -+ kapt(Dependencies.DAGGER_ANDROID_PROCESSOR) -+} -+ -+@Suppress("UNUSED_PARAMETER") -+inline fun DependencyHandler.room(){ -+ implementation(Dependencies.ROOM_RUNTIME) -+ implementation(Dependencies.ROOM_TESTING) -+ //ksp(Dependencies.ROOM_COMPILER) -+ implementation(Dependencies.ROOM_KTX) -+} -+ -+inline fun DependencyHandler.lifeCycle(){ -+ // Lifecycle component -+ implementation(Dependencies.LC_EXTENSION) -+ implementation(Dependencies.LC_JAVA8) -+ implementation(Dependencies.LC_RUNTIME) -+ kapt(Dependencies.LC_COMPILER) -+} -+ -+inline fun DependencyHandler.UITest(){ -+ androidTestImplementation(Dependencies.RECYCLER_VIEW) -+ androidTestImplementation(Dependencies.CARD_VIEW) -+ androidTestImplementation(Dependencies.GOOGLE_MATERIAL) -+ androidTestImplementation(Dependencies.RECYCLER_VIEW) -+ androidTestImplementation(Dependencies.GOOGLE_MATERIAL) -+ -+ androidTestImplementation(Dependencies.TEST_RULES) -+ androidTestImplementation(Dependencies.JUNIT_EXT) -+ androidTestImplementation(Dependencies.ARCH_CORE_TESTING) -+ androidTestImplementation(Dependencies.SWIPEX) -+ androidTestImplementation(Dependencies.MULTIDEXTEST) -+ androidTestImplementation(Dependencies.MOCKK) -+ -+ addConfigurationWithExclusion("androidTestImplementation",Dependencies.ESPRESSO_CORE) { -+ exclude(group = "com.android.support", module = "support-annotations") -+ exclude(group = "com.google.code.findbugs", module = "jsr305") -+ } -+ addConfigurationWithExclusion("androidTestImplementation",Dependencies.MOKITO_CORE -+ ) { exclude(group = "net.bytebuddy") } -+} -+/** -+ * ======================================================================================== -+ * common deps extension functions end -+ * ======================================================================================== -+ */ -+ -+ -+ -+/** -+ * ======================================================================================== -+ * plugin configuration extension functions start -+ * ======================================================================================== -+ */ -+@Deprecated( -+ message = "Use KSP instead for all kotlin annotation " + -+ "processing url:https://github.com/google/ksp") -+inline fun KaptExtension.configureKapt(){ -+ correctErrorTypes = true -+ arguments { -+ arg("-Xjvm-default", "all") -+ arg("dagger.validateTransitiveComponentDependencies", "DISABLED") -+ } -+ //jvmTarget = "11" -+ javacOptions { -+ // Increase the max count of errors from annotation processors. -+ // Default is 100. -+ option("-Xmaxerrs", 1000) -+ } -+} -+ -+inline fun configureJacoco( -+ project: Project, -+ variants: DomainObjectSet, -+ options: JacocoOptions -+) = project.run { -+ pln("configureJacoco 1") -+ variants.all { -+ val variantName = name -+ pln("configureJacoco 1$variantName") -+ val isDebuggable = true -+ if (!isDebuggable) { -+ project.logger.info("Skipping Jacoco for $name because it is not debuggable.") -+ pln("configureJacoco 2$isDebuggable") -+ return@all -+ } -+ pln("configureJacoco 33") -+ project.tasks.register("jacoco${variantName.capitalize()}Report") { -+ dependsOn(project.tasks["test${variantName.capitalize()}UnitTest"]) -+ val coverageSourceDirs = "src/main/java" -+ pln("configureJacoco 3") -+ -+ val javaClasses = project -+ .fileTree("${project.buildDir}/intermediates/javac/$variantName") { -+ setExcludes(options.excludes) -+ } -+ -+ val kotlinClasses = project -+ .fileTree("${project.buildDir}/tmp/kotlin-classes/$variantName") { -+ setExcludes(options.excludes) -+ } -+ -+ // Using the default Jacoco exec file output path. -+ val execFile = "jacoco/test${variantName.capitalize()}UnitTest.exec" -+ -+ executionData.setFrom( -+ project.fileTree("${project.buildDir}") { -+ setIncludes(listOf(execFile)) -+ } -+ ) -+ -+ // Do not run task if there's no execution data. -+ setOnlyIf { executionData.files.any { it.exists() } } -+ classDirectories.setFrom(javaClasses, kotlinClasses) -+ sourceDirectories.setFrom(coverageSourceDirs) -+ additionalSourceDirs.setFrom(coverageSourceDirs) -+ reports.xml.required.set(true) -+ reports.html.required.set(true) -+ pln("configureJacoco 4") -+ } -+ } -+} -+/** -+ * ======================================================================================== -+ * plugin configuration extension functions end -+ * ======================================================================================== -+ */ -+ -+ -+/** -+ * ======================================================================================== -+ * basic dep inline functions end -+ * ======================================================================================== -+ */ -+inline fun DependencyHandler.fragment(){ -+ implementation(Dependencies.FRAGMENT_TESTING) -+} -+ -+inline fun DependencyHandler.implementation(dependencyName: String){ -+ addConfiguration(PluginConstants.implementation,dependencyName) -+} -+ -+inline fun DependencyHandler.api(dependencyName: String){ -+ addConfiguration(PluginConstants.api,dependencyName) -+} -+ -+inline fun DependencyHandler.compileOnly(dependencyName: String){ -+ addConfiguration(PluginConstants.compileOnly,dependencyName) -+} -+ -+inline fun DependencyHandler.kapt(dependencyName: String){ -+ addConfiguration(PluginConstants.kapt,dependencyName) -+} -+ -+inline fun DependencyHandler.kaptAndroidTest(dependencyName: String){ -+ addConfiguration(PluginConstants.kaptAndroidTest,dependencyName) -+} -+ -+inline fun DependencyHandler.kaptTest(dependencyName: String){ -+ addConfiguration(PluginConstants.kaptTest,dependencyName) -+} -+ -+inline fun DependencyHandler.testImplementation(dependencyName: String){ -+ addConfiguration(PluginConstants.testImplementation,dependencyName) -+} -+ -+inline fun DependencyHandler.androidTestImplementation(dependencyName: String){ -+ addConfiguration(PluginConstants.androidTestImplementation,dependencyName) -+} -+ -+/** -+ * Adds a dependency -+ * -+ * @param configurationName configuration to be set for this dependency -+ * @param dependencyNotation notation for the dependency to be added. -+ * @return The dependency. -+ * -+ * @see [DependencyHandler.add] -+ */ -+inline fun DependencyHandler.addConfiguration(configurationName: String, dependencyNotation: Any): Dependency? = -+ add(configurationName, dependencyNotation) -+ -+ -+/** -+ * Adds a dependency -+ * -+ * @param configurationName configuration to be set for this dependency -+ * @param dependencyNotation notation for the dependency to be added. -+ * @param dependencyConfiguration expression to use to configure the dependency. -+ * @return The dependency. -+ * -+ * @see [DependencyHandler.add] -+ */ -+inline fun DependencyHandler.addConfigurationWithExclusion( -+ configurationName: String, -+ dependencyNotation: String, -+ dependencyConfiguration: Action -+): ExternalModuleDependency = addDependencyTo( -+ this, configurationName, dependencyNotation, dependencyConfiguration -+) -+ -+inline fun pln(msg: String){ -+ if(PluginConstants.enableBuildLogs){ -+ println(msg) -+ } -+} -\ No newline at end of file -Index: GitHubRepos/buildSrc/src/main/java/com/dependencies/Utility.kt -=================================================================== -diff --git a/GitHubRepos/buildSrc/src/main/java/com/dependencies/Utility.kt b/GitHubRepos/buildSrc/src/main/java/com/dependencies/Utility.kt -deleted file mode 100644 ---- a/GitHubRepos/buildSrc/src/main/java/com/dependencies/Utility.kt (revision ff4b928fab91e8dc01ee44c5260d053e4af858cb) -+++ /dev/null (revision ff4b928fab91e8dc01ee44c5260d053e4af858cb) -@@ -1,361 +0,0 @@ --/* -- * Copyright 2020 Mohammed Khalid Hamid. -- * -- * Licensed under the Apache License, Version 2.0 (the "License"); -- * you may not use this file except in compliance with the License. -- * You may obtain a copy of the License at -- * -- * http://www.apache.org/licenses/LICENSE-2.0 -- * -- * Unless required by applicable law or agreed to in writing, software -- * distributed under the License is distributed on an "AS IS" BASIS, -- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- * See the License for the specific language governing permissions and -- * limitations under the License. -- */ -- --package com.dependencies -- --import com.android.build.gradle.api.BaseVariant --import com.android.builder.model.LintOptions --import org.gradle.api.Action --import org.gradle.api.DomainObjectSet --import org.gradle.api.Project --import org.gradle.api.artifacts.Dependency --import org.gradle.api.artifacts.ExternalModuleDependency --import org.gradle.api.artifacts.dsl.DependencyHandler --import org.gradle.kotlin.dsl.* --import org.gradle.kotlin.dsl.accessors.runtime.addDependencyTo --import org.gradle.testing.jacoco.tasks.JacocoReport --import org.jetbrains.kotlin.gradle.plugin.KaptExtension --import java.io.File -- --/** -- * @author Mohammed Khalid Hamid --*/ -- --open class Utility { -- private val implementation = "implementation" -- private val kapt = "kapt" -- private val kaptTest = "kaptTest" -- private val kaptAndroidTest = "kaptAndroidTest" -- private val api = "api" -- private val compileOnly = "compileOnly" -- private val testImplementation = "testImplementation" -- private val androidTestImplementation = "androidTestImplementation" -- -- -- lateinit var ext: KPluginExtensions -- -- fun Project.applyPlugins(isApp : Boolean){ -- -- if(isApp){ -- apply(plugin = "com.android.application") -- -- // TODO: add in demo : apply(plugin = "com.google.gms.google-services") -- } else { -- apply(plugin = "com.android.library") -- apply(plugin = "org.gradle.maven-publish") -- } -- apply(plugin = "kotlin-android") -- //apply(plugin = "com.google.devtools.ksp") -- apply(plugin = "kotlin-kapt") -- apply(plugin = "org.jetbrains.kotlin.plugin.allopen") -- apply(plugin = "androidx.navigation.safeargs.kotlin") -- apply(plugin = "com.diffplug.spotless") -- apply(plugin = "org.owasp.dependencycheck") -- -- if(isApp){ -- apply(plugin = "dagger.hilt.android.plugin") -- } -- } -- -- private var lintExclusion = mutableListOf("ObsoleteLintCustomCheck", // ButterKnife will fix this in v9.0 -- "IconExpectedSize", -- "InvalidPackage", // Firestore uses GRPC which makes lint mad -- "NewerVersionAvailable", "GradleDependency", // For reproducible builds -- "SelectableText", "SyntheticAccessor") -- -- fun Project.getLintBaseline() : File { -- val defaultLintFile = file("$rootDir/quality/lint-baseline.xml") -- val lintBaseLineFilePath = ext.lintBaseLineFilePath -- if(lintBaseLineFilePath.isEmpty()) return defaultLintFile -- return file(lintBaseLineFilePath) -- } -- -- fun LintOptions.disableLint(){ -- pln(" size is "+ext.lintExclusionRules.size) -- if(ext.lintExclusionRules.isEmpty()){ -- lintExclusion.addAll(ext.lintExclusionRules) -- } -- pln(" size is "+lintExclusion.size) -- try{ -- lintExclusion.forEach { -- //disable.add(it) -- //severityOverrides.put(it, 5) -- } -- -- }catch (e : Exception){ -- e.printStackTrace() -- } -- } -- -- fun LintOptions.disableThis(rule : String){ -- //disable.add("") -- //severityOverrides -- } -- fun DependencyHandler.unitTest() { -- testImplementation(Dependencies.JUNIT) -- testImplementation(Dependencies.JUNIT_EXT) -- testImplementation(Dependencies.MOCKWEBSERVER) -- testImplementation(Dependencies.ARCH_CORE_TESTING) -- testImplementation(Dependencies.ESPRESSO_CORE) -- testImplementation(Dependencies.ESP_CONTRIBUTE) -- testImplementation(Dependencies.ESP_INTENTS) -- testImplementation(Dependencies.TEST_KTX_CORE) -- testImplementation(Dependencies.TEST_KTX_JUNIT) -- testImplementation(Dependencies.TEST_RULES) -- testImplementation(Dependencies.MOKITO_CORE) -- testImplementation(Dependencies.MOKITO_ALL) -- testImplementation(Dependencies.MOKITO_INLINE) -- testImplementation(Dependencies.CR_TEST) -- testImplementation(Dependencies.MULTIDEXTEST) -- testImplementation(Dependencies.KLUENT) -- testImplementation(Dependencies.MOCKK) -- testImplementation(Dependencies.CR_TEST_DEBUG) -- testImplementation(Dependencies.CR_TEST) -- -- //TODO: check if you need JDK9 deps. JDK9() -- } -- -- fun DependencyHandler.JDK9(){ -- compileOnly(Dependencies.jdk9Deps) -- kapt(Dependencies.jaxbApi) -- kapt(Dependencies.jaxbCore) -- kapt(Dependencies.jaxbImpl) -- } -- -- /** -- * 1. KOTLIN -- * 2. V7 -- * 3. CONSTRAINT LAYOUT -- * 4. TIMBER -- * 5. RETROFIT ADAPTER -- * 6. RETROFIT GSON CONVERTER -- * 7. RETROFIT RUNTIME -- * 8. OKHTTP -- * 9. OKHTTP INTERCEPTOR -- * 10. CARD VIEW -- * 11. GOOGLE MATERIAL -- * 12. ANNOTATIONS -- * -- */ -- fun DependencyHandler.commonAndroidLibrariers(){ -- implementation(Dependencies.KOTLIN) -- implementation(Dependencies.V7) -- implementation(Dependencies.CONSTRAINT_LAYOUT) -- implementation(Dependencies.TIMBER) -- implementation(Dependencies.SWIPEX) -- implementation(Dependencies.MULTIDEX) -- -- implementation(Dependencies.RETROFIT_ADAPTER) -- implementation(Dependencies.RETROFIT_GSON_CONVERTER) -- implementation(Dependencies.RETROFIT_RUNTIME) -- -- implementation(Dependencies.OKHTTP) -- implementation(Dependencies.OKHTTP_INTERCEPTOR) -- -- implementation(Dependencies.CARD_VIEW) -- implementation(Dependencies.GOOGLE_MATERIAL) -- implementation(Dependencies.ANNOTATIONS) -- } -- -- @Deprecated( -- message = "Use KSP instead for all kotlin annotation " + -- "processing url:https://github.com/google/ksp") -- fun KaptExtension.configureKapt(){ -- correctErrorTypes = true -- arguments { -- arg("-Xjvm-default", "all") -- arg("dagger.validateTransitiveComponentDependencies", "DISABLED") -- } -- //jvmTarget = "11" -- javacOptions { -- // Increase the max count of errors from annotation processors. -- // Default is 100. -- option("-Xmaxerrs", 1000) -- } -- } -- -- fun Project.configureJacoco( -- project: Project, -- variants: DomainObjectSet, -- options: JacocoOptions -- ) { -- pln("configureJacoco 1") -- variants.all { -- val variantName = name -- pln("configureJacoco 1$variantName") -- val isDebuggable = true -- if (!isDebuggable) { -- project.logger.info("Skipping Jacoco for $name because it is not debuggable.") -- pln("configureJacoco 2$isDebuggable") -- return@all -- } -- pln("configureJacoco 33") -- project.tasks.register("jacoco${variantName.capitalize()}Report") { -- dependsOn(project.tasks["test${variantName.capitalize()}UnitTest"]) -- val coverageSourceDirs = "src/main/java" -- pln("configureJacoco 3") -- -- val javaClasses = project -- .fileTree("${project.buildDir}/intermediates/javac/$variantName") { -- setExcludes(options.excludes) -- } -- -- val kotlinClasses = project -- .fileTree("${project.buildDir}/tmp/kotlin-classes/$variantName") { -- setExcludes(options.excludes) -- } -- -- // Using the default Jacoco exec file output path. -- val execFile = "jacoco/test${variantName.capitalize()}UnitTest.exec" -- -- executionData.setFrom( -- project.fileTree("${project.buildDir}") { -- setIncludes(listOf(execFile)) -- } -- ) -- -- // Do not run task if there's no execution data. -- setOnlyIf { executionData.files.any { it.exists() } } -- -- classDirectories.setFrom(javaClasses, kotlinClasses) -- sourceDirectories.setFrom(coverageSourceDirs) -- additionalSourceDirs.setFrom(coverageSourceDirs) -- -- reports.xml.isEnabled = true -- reports.html.isEnabled = true -- pln("configureJacoco 4") -- } -- } -- } -- -- fun DependencyHandler.UITest(){ -- androidTestImplementation(Dependencies.RECYCLER_VIEW) -- androidTestImplementation(Dependencies.CARD_VIEW) -- androidTestImplementation(Dependencies.GOOGLE_MATERIAL) -- androidTestImplementation(Dependencies.RECYCLER_VIEW) -- androidTestImplementation(Dependencies.GOOGLE_MATERIAL) -- -- androidTestImplementation(Dependencies.TEST_RULES) -- androidTestImplementation(Dependencies.JUNIT_EXT) -- androidTestImplementation(Dependencies.ARCH_CORE_TESTING) -- androidTestImplementation(Dependencies.SWIPEX) -- androidTestImplementation(Dependencies.MULTIDEXTEST) -- androidTestImplementation(Dependencies.MOCKK) -- -- addConfigurationWithExclusion("androidTestImplementation",Dependencies.ESPRESSO_CORE) { -- exclude(group = "com.android.support", module = "support-annotations") -- exclude(group = "com.google.code.findbugs", module = "jsr305") -- } -- addConfigurationWithExclusion("androidTestImplementation",Dependencies.MOKITO_CORE -- ) { exclude(group = "net.bytebuddy") } -- } -- -- @Suppress("UNUSED_PARAMETER") -- fun DependencyHandler.dagger(){ -- //implementation(Dependencies.DAGGER_RUNTIME) -- api(Dependencies.DAGGER_ANDROID) -- //implementation(Dependencies.DAGGER_ANDROID_SUPPORT) -- kapt(Dependencies.DAGGER_ANDROID_PROCESSOR) -- } -- -- @Suppress("UNUSED_PARAMETER") -- fun DependencyHandler.room(){ -- implementation(Dependencies.ROOM_RUNTIME) -- implementation(Dependencies.ROOM_TESTING) -- //ksp(Dependencies.ROOM_COMPILER) -- implementation(Dependencies.ROOM_KTX) -- } -- -- fun DependencyHandler.lifeCycle(){ -- // Lifecycle component -- implementation(Dependencies.LC_EXTENSION) -- implementation(Dependencies.LC_JAVA8) -- implementation(Dependencies.LC_RUNTIME) -- kapt(Dependencies.LC_COMPILER) -- -- } -- -- fun DependencyHandler.fragment(){ -- implementation(Dependencies.FRAGMENT_TESTING) -- } -- -- private fun DependencyHandler.implementation(dependencyName: String){ -- addConfiguration(implementation,dependencyName) -- } -- -- private fun DependencyHandler.api(dependencyName: String){ -- addConfiguration(api,dependencyName) -- } -- -- private fun DependencyHandler.compileOnly(dependencyName: String){ -- addConfiguration(compileOnly,dependencyName) -- } -- -- private fun DependencyHandler.kapt(dependencyName: String){ -- addConfiguration(kapt,dependencyName) -- } -- -- private fun DependencyHandler.kaptAndroidTest(dependencyName: String){ -- addConfiguration(kaptAndroidTest,dependencyName) -- } -- -- private fun DependencyHandler.kaptTest(dependencyName: String){ -- addConfiguration(kaptTest,dependencyName) -- } -- -- private fun DependencyHandler.testImplementation(dependencyName: String){ -- addConfiguration(testImplementation,dependencyName) -- } -- -- private fun DependencyHandler.androidTestImplementation(dependencyName: String){ -- addConfiguration(androidTestImplementation,dependencyName) -- } -- -- /** -- * Adds a dependency -- * -- * @param configurationName configuration to be set for this dependency -- * @param dependencyNotation notation for the dependency to be added. -- * @return The dependency. -- * -- * @see [DependencyHandler.add] -- */ -- private fun DependencyHandler.addConfiguration(configurationName: String, dependencyNotation: Any): Dependency? = -- add(configurationName, dependencyNotation) -- -- -- /** -- * Adds a dependency -- * -- * @param configurationName configuration to be set for this dependency -- * @param dependencyNotation notation for the dependency to be added. -- * @param dependencyConfiguration expression to use to configure the dependency. -- * @return The dependency. -- * -- * @see [DependencyHandler.add] -- */ -- private fun DependencyHandler.addConfigurationWithExclusion( -- configurationName: String, -- dependencyNotation: String, -- dependencyConfiguration: Action -- ): ExternalModuleDependency = addDependencyTo( -- this, configurationName, dependencyNotation, dependencyConfiguration -- ) --} -- --inline fun pln(msg: String){ -- //println(msg) --} -\ No newline at end of file -Index: GitHubRepos/gradle.properties -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>ISO-8859-1 -=================================================================== -diff --git a/GitHubRepos/gradle.properties b/GitHubRepos/gradle.properties ---- a/GitHubRepos/gradle.properties (revision ff4b928fab91e8dc01ee44c5260d053e4af858cb) -+++ b/GitHubRepos/gradle.properties (revision 8364b20725d554ae538e6217c06ffe75004867c2) -@@ -35,4 +35,6 @@ - # Kotlin code style for this project: "official" or "obsolete": - kotlin.code.style=official - -+# KhalidAndroidPlugin properties -+enableBuildLogs = true - -Index: GitHubRepos/library/build.gradle.kts -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>UTF-8 -=================================================================== -diff --git a/GitHubRepos/library/build.gradle.kts b/GitHubRepos/library/build.gradle.kts ---- a/GitHubRepos/library/build.gradle.kts (revision ff4b928fab91e8dc01ee44c5260d053e4af858cb) -+++ b/GitHubRepos/library/build.gradle.kts (revision 8364b20725d554ae538e6217c06ffe75004867c2) -@@ -3,12 +3,6 @@ - plugins { - id("com.khalid.hamid.KhalidAndroidPlugin") - } --kapt { -- correctErrorTypes = true -- arguments { -- arg("-Xjvm-default", "compatibility") -- } --} - - KPlugin { - println("Library ... ") diff --git a/GitHubRepos/sonar-project.properties b/GitHubRepos/sonar-project.properties new file mode 100644 index 00000000..0e3830b9 --- /dev/null +++ b/GitHubRepos/sonar-project.properties @@ -0,0 +1,11 @@ +sonar.projectKey=khalid64927 +sonar.projectName=AndroidCore +sonar.sourceEncoding=UTF-8 +sonar.language=kotlin +sonar.organization=Khalid +sonar.sources=app/src/main,app/src/prod,app/src/release +sonar.java.binaries=app/build/tmp/kotlin-classes/mockDebug,app/build/tmp/kotlin-classes/prodDebug +sonar.exclusions=**/test/*/** +sonar.java.coveragePlugin=jacoco +sonar.coverage.jacoco.xmlReportPaths=reports/jacoco/jacocoMockDebugReport/jacocoFullReport.xml +sonar.dynamicAnalysis=reuseReports \ No newline at end of file