|
1 |
| -/* |
2 |
| - * This file was generated by the Gradle 'init' task. |
3 |
| - * |
4 |
| - * This generated file contains a sample Kotlin library project to get you started. |
5 |
| - */ |
| 1 | +import io.gitlab.arturbosch.detekt.detekt |
| 2 | +import org.jetbrains.dokka.gradle.DokkaTask |
| 3 | +import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin |
6 | 4 |
|
7 | 5 | plugins {
|
8 |
| - // Apply the Kotlin JVM plugin to add support for Kotlin on the JVM. |
9 |
| - id("org.jetbrains.kotlin.jvm").version("1.3.21") |
| 6 | + base |
| 7 | + kotlin("jvm") version "1.3.31" apply false |
| 8 | + id("io.gitlab.arturbosch.detekt") version "1.0.0-RC12" apply false |
| 9 | + id("org.jetbrains.dokka") version "0.9.17" apply false |
10 | 10 | }
|
11 | 11 |
|
12 |
| -repositories { |
13 |
| - // Use jcenter for resolving your dependencies. |
14 |
| - // You can declare any Maven/Ivy/file repository here. |
15 |
| - jcenter() |
| 12 | +allprojects { |
| 13 | + |
| 14 | + repositories { |
| 15 | + mavenCentral() |
| 16 | + jcenter() |
| 17 | + } |
16 | 18 | }
|
17 | 19 |
|
18 |
| -dependencies { |
19 |
| - // Use the Kotlin JDK 8 standard library. |
20 |
| - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") |
| 20 | +subprojects { |
| 21 | + |
| 22 | + apply { |
| 23 | + plugin<JavaLibraryPlugin>() |
| 24 | + plugin<KotlinPlatformJvmPlugin>() |
| 25 | + plugin("io.gitlab.arturbosch.detekt") |
| 26 | + plugin("jacoco") |
| 27 | + |
| 28 | + plugin("org.jetbrains.dokka") |
| 29 | + plugin("maven-publish") |
| 30 | + } |
| 31 | + |
| 32 | + val sourceSets = project.the<SourceSetContainer>() |
| 33 | + |
| 34 | + val sourcesJar by tasks.creating(Jar::class) { |
| 35 | + from(sourceSets["main"].allSource) |
| 36 | + archiveClassifier.set("sources") |
| 37 | + } |
| 38 | + |
| 39 | + // Configure existing Dokka task to output HTML to typical Javadoc directory |
| 40 | + val dokka by tasks.getting(DokkaTask::class) { |
| 41 | + outputFormat = "html" |
| 42 | + outputDirectory = "$buildDir/javadoc" |
| 43 | + } |
| 44 | + |
| 45 | + // Create dokka Jar task from dokka task output |
| 46 | + val dokkaJar by tasks.creating(Jar::class) { |
| 47 | + group = JavaBasePlugin.DOCUMENTATION_GROUP |
| 48 | + description = "Assembles Kotlin docs with Dokka" |
| 49 | + archiveClassifier.set("javadoc") |
| 50 | + // dependsOn(tasks.dokka) not needed; dependency automatically inferred by from(tasks.dokka) |
| 51 | + from(dokka) |
| 52 | + } |
| 53 | + |
| 54 | + tasks.withType<Test> { |
| 55 | + useJUnitPlatform() |
| 56 | + |
| 57 | + testLogging { |
| 58 | + events("FAILED") |
| 59 | + } |
| 60 | + |
| 61 | + maxParallelForks = Runtime.getRuntime().availableProcessors() |
| 62 | + setForkEvery(1L) |
| 63 | + } |
| 64 | + |
| 65 | + detekt { |
| 66 | + description = "Runs a failfast detekt build." |
| 67 | + |
| 68 | + input = files("src/main/kotlin") |
| 69 | + config = files("../detekt.yml") |
| 70 | + filters = ".*/build/.*" |
| 71 | + |
| 72 | + reports { |
| 73 | + xml.enabled = false |
| 74 | + html.enabled = true |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + // jacoco |
| 79 | + configure<JacocoPluginExtension> { |
| 80 | + } |
21 | 81 |
|
22 |
| - // Use the Kotlin test library. |
23 |
| - testImplementation("org.jetbrains.kotlin:kotlin-test") |
| 82 | + tasks.withType<JacocoReport> { |
| 83 | + reports { |
| 84 | + html.isEnabled = true |
| 85 | + xml.isEnabled = true |
| 86 | + csv.isEnabled = false |
| 87 | + } |
| 88 | + } |
24 | 89 |
|
25 |
| - // Use the Kotlin JUnit integration. |
26 |
| - testImplementation("org.jetbrains.kotlin:kotlin-test-junit") |
| 90 | + tasks["clean"].doLast { |
| 91 | + delete("./.project") |
| 92 | + delete("./out") |
| 93 | + delete("./bin") |
| 94 | + } |
27 | 95 | }
|
0 commit comments