Created
September 27, 2023 04:25
-
-
Save VahidGarousi/94ed954f905f27f6acb3892d3c56d381 to your computer and use it in GitHub Desktop.
Detekt in Gradle Convention for Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AndroidLibraryConventionPlugin : Plugin<Project> { | |
override fun apply(target: Project) { | |
with(target) { | |
with(pluginManager) { | |
apply("com.android.library") | |
apply("org.jetbrains.kotlin.android") | |
apply("composenews.android.detekt") // here | |
apply("composenews.android.ktlint") | |
} | |
extensions.configure<LibraryExtension> { | |
configureKotlinAndroid(this) | |
defaultConfig.targetSdk = Integer.parseInt(libs.findVersion("projectTargetSdkVersion").get().toString()) | |
} | |
dependencies { | |
add("androidTestImplementation", kotlin("test")) | |
add("testImplementation", kotlin("test")) | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal fun Project.configureDetekt(extension: DetektExtension) = extension.apply { | |
tasks.named<Detekt>("detekt") { | |
reports { | |
xml.required.set(true) | |
html.required.set(true) | |
txt.required.set(true) | |
sarif.required.set(true) | |
md.required.set(true) | |
} | |
} | |
dependencies { | |
"detektPlugins"(libs.findLibrary("detekt-formatting").get()) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[versions] | |
detekt="1.23.1" | |
[libereries] | |
detekt-gradlePlugin = { group = "io.gitlab.arturbosch.detekt", name = "detekt-gradle-plugin", version.ref = "detekt" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment