All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gradle-plugins.code-analysis.0.1.0-rc.15.source-code.CodeAnalysisPlugin.kt Maven / Gradle / Ivy

There is a newer version: 0.1.0-rc.45
Show newest version
package com.javiersc.gradle.plugins.code.analysis

import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import java.io.File
import org.gradle.api.Plugin
import org.gradle.api.Project

abstract class CodeAnalysisPlugin : Plugin {

    override fun apply(target: Project) {
        target.pluginManager.apply("io.gitlab.arturbosch.detekt")
        target.extensions.findByType(DetektExtension::class.java)?.apply {
            parallel = true
            isIgnoreFailures = true
            buildUponDefaultConfig = true
            basePath = target.rootProject.projectDir.path
        }

        target.tasks.withType(Detekt::class.java).configureEach { detekt ->
            detekt.setSource(detekt.project.files(detekt.project.projectDir))
            detekt.include("**/*.kt")
            detekt.include("**/*.kts")
            detekt.exclude("**/resources/**")
            detekt.exclude("**/build/**")

            detekt.reports { report ->
                report.html { enabled = true }
                report.sarif { enabled = true }
                report.txt { enabled = false }
                report.xml { enabled = false }
            }
        }

        File("${target.rootProject.rootDir}/.idea/detekt.xml").apply {
            parentFile.mkdirs()
            createNewFile()
            writeText(
                """
                    
                    
                      
                        true
                        true
                        true
                      
                    
                """.trimIndent()
            )
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy