|
| 1 | +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
| 2 | + |
| 3 | +plugins { |
| 4 | + kotlin("jvm") |
| 5 | + kotlin("kapt") |
| 6 | + id("org.jetbrains.dokka") |
| 7 | + |
| 8 | + signing |
| 9 | + `maven-publish` |
| 10 | +} |
| 11 | + |
| 12 | +dependencies { |
| 13 | + compileOnly("org.jetbrains.kotlin:kotlin-compiler") |
| 14 | + |
| 15 | + kapt("com.google.auto.service:auto-service:1.0-rc6") |
| 16 | + compileOnly("com.google.auto.service:auto-service-annotations:1.0-rc6") |
| 17 | +} |
| 18 | + |
| 19 | +tasks.named("compileKotlin") { dependsOn("syncSource") } |
| 20 | +tasks.register<Sync>("syncSource") { |
| 21 | + from(project(":kotlin-power-assert-plugin").sourceSets.main.get().allSource) |
| 22 | + into("src/main/kotlin") |
| 23 | + filter { |
| 24 | + // Replace shadowed imports from kotlin-power-assert-plugin |
| 25 | + when (it) { |
| 26 | + "import org.jetbrains.kotlin.com.intellij.mock.MockProject" -> "import com.intellij.mock.MockProject" |
| 27 | + else -> it |
| 28 | + } |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +tasks.withType<KotlinCompile> { |
| 33 | + kotlinOptions.jvmTarget = "1.8" |
| 34 | +} |
| 35 | + |
| 36 | +tasks.dokka { |
| 37 | + outputFormat = "html" |
| 38 | + outputDirectory = "$buildDir/javadoc" |
| 39 | +} |
| 40 | + |
| 41 | +tasks.register("sourcesJar", Jar::class) { |
| 42 | + group = "build" |
| 43 | + description = "Assembles Kotlin sources" |
| 44 | + |
| 45 | + archiveClassifier.set("sources") |
| 46 | + from(sourceSets.main.get().allSource) |
| 47 | + dependsOn(tasks.classes) |
| 48 | +} |
| 49 | + |
| 50 | +tasks.register("dokkaJar", Jar::class) { |
| 51 | + group = "documentation" |
| 52 | + description = "Assembles Kotlin docs with Dokka" |
| 53 | + |
| 54 | + archiveClassifier.set("javadoc") |
| 55 | + from(tasks.dokka) |
| 56 | + dependsOn(tasks.dokka) |
| 57 | +} |
| 58 | + |
| 59 | +signing { |
| 60 | + setRequired(provider { gradle.taskGraph.hasTask("publish") }) |
| 61 | + sign(publishing.publications) |
| 62 | +} |
| 63 | + |
| 64 | +publishing { |
| 65 | + publications { |
| 66 | + create<MavenPublication>("default") { |
| 67 | + from(components["java"]) |
| 68 | + artifact(tasks["sourcesJar"]) |
| 69 | + artifact(tasks["dokkaJar"]) |
| 70 | + |
| 71 | + pom { |
| 72 | + name.set(project.name) |
| 73 | + description.set("Kotlin compiler plugin to enable power assertions in the Kotlin programming language") |
| 74 | + url.set("https://github.com/bnorm/kotlin-power-assert") |
| 75 | + |
| 76 | + licenses { |
| 77 | + license { |
| 78 | + name.set("Apache License 2.0") |
| 79 | + url.set("https://github.com/bnorm/kotlin-power-assert/blob/master/LICENSE.txt") |
| 80 | + } |
| 81 | + } |
| 82 | + scm { |
| 83 | + url.set("https://github.com/bnorm/kotlin-power-assert") |
| 84 | + connection.set("scm:git:git://github.com/bnorm/kotlin-power-assert.git") |
| 85 | + } |
| 86 | + developers { |
| 87 | + developer { |
| 88 | + name.set("Brian Norman") |
| 89 | + url.set("https://github.com/bnorm") |
| 90 | + } |
| 91 | + } |
| 92 | + } |
| 93 | + } |
| 94 | + } |
| 95 | + |
| 96 | + repositories { |
| 97 | + if ( |
| 98 | + hasProperty("sonatypeUsername") && |
| 99 | + hasProperty("sonatypePassword") && |
| 100 | + hasProperty("sonatypeSnapshotUrl") && |
| 101 | + hasProperty("sonatypeReleaseUrl") |
| 102 | + ) { |
| 103 | + maven { |
| 104 | + val url = when { |
| 105 | + "SNAPSHOT" in version.toString() -> property("sonatypeSnapshotUrl") |
| 106 | + else -> property("sonatypeReleaseUrl") |
| 107 | + } as String |
| 108 | + setUrl(url) |
| 109 | + credentials { |
| 110 | + username = property("sonatypeUsername") as String |
| 111 | + password = property("sonatypePassword") as String |
| 112 | + } |
| 113 | + } |
| 114 | + } |
| 115 | + maven { |
| 116 | + name = "test" |
| 117 | + setUrl("file://${rootProject.buildDir}/localMaven") |
| 118 | + } |
| 119 | + } |
| 120 | +} |
0 commit comments