Vivek Krishnan
04/15/2021, 9:40 AMid("io.gitlab.arturbosch.detekt") version "1.16.0" apply true
in my plugins section
2. added jcenter()
into my repositories section
3. In the subproject section, I’ve added a task to register detekAll
* What went wrong:
Script compilation errors:
Line 58: def autoFix = project.hasProperty('detektAutoFix')
^ Expecting an element
Line 58: def autoFix = project.hasProperty('detektAutoFix')
^ Expecting an element
Line 55: tasks.register()
^ None of the following functions can be called with the arguments supplied:
public abstract fun register(p0: String!): TaskProvider<Task!>! defined in org.gradle.api.tasks.TaskContainer
public abstract fun <T : Task!> register(p0: String!, p1: Class<TypeVariable(T)!>!): TaskProvider<TypeVariable(T)!>! defined in org.gradle.api.tasks.TaskContainer
public abstract fun <T : Task!> register(p0: String!, p1: Class<TypeVariable(T)!>!, vararg p2: Any!): TaskProvider<TypeVariable(T)!>! defined in org.gradle.api.tasks.TaskContainer
public abstract fun <T : Task!> register(p0: String!, p1: Class<TypeVariable(T)!>!, p2: Action<in TypeVariable(T)!>!): TaskProvider<TypeVariable(T)!>! defined in org.gradle.api.tasks.TaskContainer
public abstract fun register(p0: String!, p1: Action<in Task!>!): TaskProvider<Task!>! defined in org.gradle.api.tasks.TaskContainer
Line 57: tasks.register("detektAll", io.gitlab.arturbosch.detekt.Detekt) {
^ Not enough information to infer type variable T
Line 57: tasks.register("detektAll", io.gitlab.arturbosch.detekt.Detekt) {
^ Classifier 'Detekt' does not have a companion object, and thus must be initialized here
Line 58: def autoFix = project.hasProperty('detektAutoFix')
^ Too many characters in a character literal ''detektAutoFix''
Line 60: description = "Custom DETEKT build for all modules"
^ Variable expected
Line 61: parallel = true
^ Variable expected
Line 62: ignoreFailures = false
^ Variable expected
Line 63: autoCorrect = autoFix
^ Variable expected
Line 64: buildUponDefaultConfig = true
^ Variable expected
Line 71: html.enabled = true
^ Variable expected
Line 72: xml.enabled = false
^ Variable expected
Line 73: txt.enabled = false
^ Variable expected
gammax
04/15/2021, 9:43 AMVivek Krishnan
04/15/2021, 9:46 AMimport 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")
}
}