mirror of
https://github.com/jlengrand/detekt.git
synced 2026-03-10 08:11:23 +00:00
Add kotlin dsl gradle task configuration in gradletask.md (#3686)
* Add kotlin dsl gradle task configuration in gradletask.md * Remove jcenter from gradle task configuration example in the docs
This commit is contained in:
@@ -219,6 +219,7 @@ If you contributed to detekt but your name is not in the list, please feel free
|
||||
- [Krzysztof Kruczynski](https://github.com/krzykrucz) - Rule fix: ThrowingExceptionInMain, ExitOutsideMain
|
||||
- [Paya Do](https://github.com/payathedo) - Designer for Detekt's logo
|
||||
- [zmunm](https://github.com/zmunm) - New rule: ObjectLiteralToLambda
|
||||
- [Vinicius Montes Munhoz](https://github.com/vfmunhoz) - Documentation improvement
|
||||
- [Eliezer Graber](https://github.com/eygraber) - Rule fix: ModifierOrder
|
||||
- [Dominik Labuda](https://github.com/Dominick1993) - Gradle plugin improvement
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ summary:
|
||||
|
||||
1. Add following lines to your build.gradle file.
|
||||
2. Run `gradle detekt`
|
||||
3. Add `check.dependsOn detekt` if you want to run _detekt_ on every `build`
|
||||
|
||||
###### Groovy DSL
|
||||
```groovy
|
||||
@@ -24,19 +23,49 @@ configurations {
|
||||
task detekt(type: JavaExec) {
|
||||
main = "io.gitlab.arturbosch.detekt.cli.Main"
|
||||
classpath = configurations.detekt
|
||||
|
||||
def input = "$projectDir"
|
||||
def config = "$projectDir/detekt.yml"
|
||||
def exclude = ".*/build/.*,.*/resources/.*"
|
||||
def params = [ '-i', input, '-c', config, '-ex', exclude]
|
||||
|
||||
args(params)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
detekt 'io.gitlab.arturbosch.detekt:detekt-cli:{{ site.detekt_version }}'
|
||||
}
|
||||
|
||||
// Remove this line if you don't want to run detekt on every build
|
||||
check.dependsOn detekt
|
||||
```
|
||||
|
||||
###### Kotlin DSL
|
||||
```kotlin
|
||||
// TODO
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
val detekt by configurations.creating
|
||||
|
||||
val detektTask = tasks.register<JavaExec>("detekt") {
|
||||
main = "io.gitlab.arturbosch.detekt.cli.Main"
|
||||
classpath = detekt
|
||||
|
||||
val input = projectDir
|
||||
val config = "$projectDir/detekt.yml"
|
||||
val exclude = ".*/build/.*,.*/resources/.*"
|
||||
val params = listOf("-i", input, "-c", config, "-ex", exclude)
|
||||
|
||||
args(params)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
detekt("io.gitlab.arturbosch.detekt:detekt-cli:{{ site.detekt_version }}")
|
||||
}
|
||||
|
||||
// Remove this block if you don't want to run detekt on every build
|
||||
tasks.check {
|
||||
dependsOn(detektTask)
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user