https://kotlinlang.org logo
#detekt
Title
# detekt
v

Vivek Krishnan

04/19/2021, 8:47 AM
Copy code
import org.gradle.plugins.ide.idea.model.IdeaLanguageLevel
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.plugin.SpringBootPlugin
import org.springframework.boot.gradle.tasks.run.BootRun

plugins {
    base
    id("com.dorongold.task-tree") version "1.4"
    id("org.springframework.boot") version "2.4.1" apply false
    kotlin("jvm") version "1.4.21"
    kotlin("plugin.spring") version "1.4.21" apply false
    id("org.sonarqube") version "3.1.1"
    idea
    jacoco
    id("io.gitlab.arturbosch.detekt") version "1.16.0" apply true
}

group = "com.abc.engine"

allprojects {
    val runningOnGitlabCI = System.getenv("GITLAB_CI")?.toBoolean() == true

    version = when {
        runningOnGitlabCI -> System.getenv("CI_COMMIT_TAG") ?: System.getenv("CI_PIPELINE_ID") ?: "ci_undefined"
        else -> "undefined"
    }

    repositories {
        mavenCentral()
        maven(url = "<https://oss.jfrog.org/artifactory/oss-snapshot-local/>")
        jcenter()
    }
}

val SRC_ENCODING = "UTF-8"
val SRC_VERSION = 11

idea {
    project {
        jdkName = "$SRC_VERSION"
        languageLevel = IdeaLanguageLevel("$SRC_VERSION")
        vcs = "Git"
    }

    module {
        excludeDirs = excludeDirs + file(".gradle/")
    }
}

subprojects {
    apply(plugin = "kotlin")
    apply(plugin = "jacoco")
    apply(plugin = "detek")

//    tasks.register()

//    tasks.register("detektAll", io.gitlab.arturbosch.detekt.Detekt) {
//        def autoFix = project.hasProperty('detektAutoFix')
//
//        description = "Custom DETEKT build for all modules"
//        parallel = true
//        ignoreFailures = false
//        autoCorrect = autoFix
//        buildUponDefaultConfig = true
//        setSource(projectSource)
//        baseline.set(baselineFile)
//        config.setFrom(configFile)
//        include(kotlinFiles)
//        exclude(resourceFiles, buildFiles)
//        reports {
//            html.enabled = true
//            xml.enabled = false
//            txt.enabled = false
//        }
//    }

//    tasks.register("detektGenerateBaseline", io.gitlab.arturbosch.detekt.DetektCreateBaselineTask) {
//        description = "Custom DETEKT build to build baseline for all modules"
//        parallel = true
//        ignoreFailures = false
//        buildUponDefaultConfig = true
//        setSource(projectSource)
//        baseline.set(baselineFile)
//        config.setFrom(configFile)
//        include(kotlinFiles)
//        exclude(resourceFiles, buildFiles)
//    }

    tasks.withType<Test>().configureEach {
        useJUnitPlatform()
        testLogging {
            events("failed")
        }
        maxParallelForks = Runtime.getRuntime().availableProcessors()

    }

    tasks.withType<KotlinCompile>().configureEach {
        kotlinOptions {
            jvmTarget = "11"
            kotlinOptions.useIR = true
        }
    }

    tasks.withType<BootRun>().configureEach {
        val profiles = System.getenv("SPRING_PROFILES_ACTIVE")
        if (profiles == null || profiles.trim() == "") {
            val springProfilesActive = project.gradle.startParameter.systemPropertiesArgs["spring.profiles.active"]
                    ?: "localdev"
            args = ((args ?: emptyList()) + "--spring.profiles.active=$springProfilesActive")
        }
        jvmArgs = listOf("-Xmx512m")
    }

    tasks.check {
        finalizedBy(tasks.jacocoTestReport)
    }

    tasks.jacocoTestReport {
        dependsOn(tasks.test)
        reports {
            xml.isEnabled = true
            csv.isEnabled = false
            html.isEnabled = false
        }
    }

    // global dependencies configuration
    dependencies {
        "annotationProcessor"(platform(SpringBootPlugin.BOM_COORDINATES))

        "implementation"(platform(SpringBootPlugin.BOM_COORDINATES))
        "implementation"(enforcedPlatform("com.amazonaws:aws-java-sdk-bom:1.11.862")) // amazon v1 bom
        "implementation"(enforcedPlatform("software.amazon.awssdk:bom:2.14.19")) // amazon v2 bom
        "implementation"(kotlin("stdlib"))
        "implementation"(kotlin("reflect"))

        "compileOnly"(platform(SpringBootPlugin.BOM_COORDINATES))
        "compileOnly"("org.springframework.boot:spring-boot-configuration-processor")

        "testImplementation"(platform(SpringBootPlugin.BOM_COORDINATES))
        "testImplementation"("org.junit.jupiter:junit-jupiter-api")
        "testImplementation"("org.junit.jupiter:junit-jupiter-params")

        "testRuntimeOnly"(platform(SpringBootPlugin.BOM_COORDINATES))
        "testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine")
//        "detektPlugins"("io.gitlab.arturbosch.detekt:detekt-formatting:1.16.0")
    }
}
g

gammax

04/19/2021, 9:37 AM
Can you also share your project? So I can check it out and take a look? From a quick look, the file looks ok to me at first.
v

Vivek Krishnan

04/19/2021, 2:35 PM
@gammax, am afraid that the project is not open source and am unable to share the project
g

gammax

04/19/2021, 2:35 PM
Then can I ask you to create a reproducer?
v

Vivek Krishnan

04/19/2021, 2:36 PM
ok, what exactly are you looking for?
g

gammax

04/19/2021, 2:36 PM
A project that I can open locally, with this build.gradle file. I would like to try to reproduce the errors you’re facing.
v

Vivek Krishnan

04/19/2021, 2:37 PM
ok, let me try that!
2 Views