update static plugin #11
|
|
@ -36,11 +36,11 @@ class StaticAnalysisAndroidPlugin : StaticAnalysisPlugin() {
|
||||||
|
|
||||||
override fun createLinters(extension: StaticAnalysisExtension): List<Linter> = mutableListOf<Linter>().apply {
|
override fun createLinters(extension: StaticAnalysisExtension): List<Linter> = mutableListOf<Linter>().apply {
|
||||||
add(DetektLinter())
|
add(DetektLinter())
|
||||||
if (extension.isCpdLinterEnabled) {
|
if (extension.needCpdLinterEnabled) {
|
||||||
CpdLinter()
|
add(CpdLinter())
|
||||||
}
|
}
|
||||||
if (extension.isAndroidLinterEnabled) {
|
if (extension.needAndroidLinterEnabled) {
|
||||||
AndroidLinter()
|
add(AndroidLinter())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@ package static_analysis.plugins
|
||||||
open class StaticAnalysisExtension(
|
open class StaticAnalysisExtension(
|
||||||
var excludes: String = "",
|
var excludes: String = "",
|
||||||
var buildScriptDir: String? = null,
|
var buildScriptDir: String? = null,
|
||||||
var isCpdLinterEnabled: Boolean = true,
|
var needCpdLinterEnabled: Boolean = true,
|
||||||
var isAndroidLinterEnabled: Boolean = false,
|
var needAndroidLinterEnabled: Boolean = false,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,24 @@ abstract class StaticAnalysisPlugin : Plugin<Project> {
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract fun createLinters(extension: StaticAnalysisExtension): List<Linter>
|
abstract fun createLinters(extension: StaticAnalysisExtension): List<Linter>
|
||||||
|
|
||||||
abstract fun createStaticAnalysisTasks(project: Project, linters: List<Linter>)
|
abstract fun createStaticAnalysisTasks(project: Project, linters: List<Linter>)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project level
|
||||||
|
*
|
||||||
|
* В gradle.kts используйте этот extension.
|
||||||
|
*
|
||||||
|
* В классическом gradle, синтаксис ровно тот, же, но без использования extension.
|
||||||
|
* ```
|
||||||
|
* staticAnalysis {
|
||||||
|
* excludes = ":name_example"
|
||||||
|
* buildScriptDir = buildScriptsDirectory
|
||||||
|
* needCpdLinterEnabled = false
|
||||||
|
* needAndroidLinterEnabled = false
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
fun Project.staticAnalysis(configure: Action<StaticAnalysisExtension>): Unit =
|
fun Project.staticAnalysis(configure: Action<StaticAnalysisExtension>): Unit =
|
||||||
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure(STATIC_ANALYSIS_EXT_NAME, configure)
|
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure(STATIC_ANALYSIS_EXT_NAME, configure)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue