|
| 1 | +import com.jfrog.bintray.gradle.BintrayExtension |
| 2 | +import com.jfrog.bintray.gradle.BintrayExtension.* |
| 3 | +import groovy.util.Node |
| 4 | +import org.gradle.jvm.tasks.Jar |
| 5 | +import java.net.URL |
| 6 | +import org.jetbrains.dokka.DokkaConfiguration |
| 7 | +import org.jetbrains.dokka.gradle.DokkaTask |
| 8 | +import org.jetbrains.dokka.gradle.LinkMapping |
| 9 | +import org.jetbrains.kotlin.builtins.isNumberedFunctionClassFqName |
| 10 | +import org.jetbrains.kotlin.gradle.dsl.Coroutines |
| 11 | +import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin |
| 12 | +import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper |
| 13 | + |
| 14 | +plugins { |
| 15 | + id("org.jetbrains.kotlin.jvm") version "1.2.40" |
| 16 | + id("com.jfrog.bintray") version "1.7.3" |
| 17 | + jacoco |
| 18 | + `maven-publish` |
| 19 | + id("org.jetbrains.dokka") version "0.9.16" |
| 20 | +} |
| 21 | + |
| 22 | +group = "ru.gildor.coroutines" |
| 23 | +version = "0.10.0" |
| 24 | +description = "Provides Kotlin Coroutines suspendable await() extensions for Retrofit Call" |
| 25 | + |
| 26 | +repositories { |
| 27 | + jcenter() |
| 28 | +} |
| 29 | + |
| 30 | +java { |
| 31 | + targetCompatibility = JavaVersion.VERSION_1_6 |
| 32 | + sourceCompatibility = JavaVersion.VERSION_1_6 |
| 33 | +} |
| 34 | + |
| 35 | +dependencies { |
| 36 | + compile("org.jetbrains.kotlin:kotlin-stdlib") |
| 37 | + compile("org.jetbrains.kotlinx:kotlinx-coroutines-core:0.22.5") |
| 38 | + compile("com.squareup.retrofit2:retrofit:2.4.0") |
| 39 | + testCompile("junit:junit:4.12") |
| 40 | +} |
| 41 | + |
| 42 | +kotlin { |
| 43 | + experimental.coroutines = Coroutines.ENABLE |
| 44 | +} |
| 45 | + |
| 46 | +/* Code coverage */ |
| 47 | + |
| 48 | +val jacocoTestReport by tasks.getting(JacocoReport::class) { |
| 49 | + reports.xml.isEnabled = true |
| 50 | +} |
| 51 | + |
| 52 | +val test by tasks.getting { |
| 53 | + finalizedBy(jacocoTestReport) |
| 54 | +} |
| 55 | + |
| 56 | +/* KDoc */ |
| 57 | + |
| 58 | +val dokka by tasks.getting(DokkaTask::class) { |
| 59 | + outputFormat = "javadoc" |
| 60 | + outputDirectory = "$buildDir/javadoc" |
| 61 | + |
| 62 | + externalDocumentationLink(delegateClosureOf<DokkaConfiguration.ExternalDocumentationLink.Builder> { |
| 63 | + url = URL("https://square.github.io/okhttp/3.x/okhttp/") |
| 64 | + }) |
| 65 | + externalDocumentationLink(delegateClosureOf<DokkaConfiguration.ExternalDocumentationLink.Builder> { |
| 66 | + url = URL("https://square.github.io/retrofit/2.x/retrofit/") |
| 67 | + }) |
| 68 | +} |
| 69 | + |
| 70 | +/* Publishing */ |
| 71 | + |
| 72 | +val githubId = "gildor/kotlin-coroutines-retrofit" |
| 73 | +val repoWeb = "https://github.com/$githubId" |
| 74 | +val repoVcs = "$repoWeb.git" |
| 75 | +val tags = listOf("retrofit", "kotlin", "coroutines") |
| 76 | +val licenseId = "Apache-2.0" |
| 77 | +val licenseName = "The Apache Software License, Version 2.0" |
| 78 | +val licenseUrl = "http://www.apache.org/licenses/LICENSE-2.0.txt" |
| 79 | +val releaseTag = "v${project.version}" |
| 80 | + |
| 81 | +val sourcesJar by tasks.creating(Jar::class) { |
| 82 | + dependsOn("classes") |
| 83 | + classifier = "sources" |
| 84 | + from(java.sourceSets["main"].allSource) |
| 85 | +} |
| 86 | + |
| 87 | +val javadocJar by tasks.creating(Jar::class) { |
| 88 | + dependsOn(dokka) |
| 89 | + classifier = "javadoc" |
| 90 | + from("$buildDir/javadoc") |
| 91 | +} |
| 92 | + |
| 93 | +publishing { |
| 94 | + publications { |
| 95 | + create("MavenJava", MavenPublication::class.java) { |
| 96 | + from(components["java"]) |
| 97 | + artifact(sourcesJar) |
| 98 | + artifact(javadocJar) |
| 99 | + pom.withXml { |
| 100 | + NodeScope(asNode()) { |
| 101 | + "name" to project.name |
| 102 | + "description" to project.description.toString() |
| 103 | + "url" to repoWeb |
| 104 | + "developers" { |
| 105 | + "developer" { |
| 106 | + "name" to "Andrey Mischenko" |
| 107 | + |
| 108 | + "organizationUrl" to "https://github.com/gildor" |
| 109 | + } |
| 110 | + } |
| 111 | + "issueManagement" { |
| 112 | + "system" to "GitHub Issues" |
| 113 | + "url" to "$repoWeb/issues" |
| 114 | + } |
| 115 | + "scm" { |
| 116 | + "url" to repoWeb |
| 117 | + "connection" to "scm:git:$repoVcs" |
| 118 | + "developerConnection" to "scm:git:$repoVcs" |
| 119 | + "tag" to releaseTag |
| 120 | + } |
| 121 | + "licenses" { |
| 122 | + "license" { |
| 123 | + "name" to licenseName |
| 124 | + "url" to licenseUrl |
| 125 | + } |
| 126 | + } |
| 127 | + } |
| 128 | + } |
| 129 | + } |
| 130 | + } |
| 131 | +} |
| 132 | + |
| 133 | +bintray { |
| 134 | + user = project.properties["bintray.user"]?.toString() |
| 135 | + key = project.properties["bintray.key"]?.toString() |
| 136 | + setPublications("MavenJava") |
| 137 | + publish = true |
| 138 | + pkg(delegateClosureOf<PackageConfig> { |
| 139 | + repo = project.properties["bintray.repo"]?.toString() ?: "maven" |
| 140 | + name = project.name |
| 141 | + desc = description |
| 142 | + githubRepo = githubId |
| 143 | + githubReleaseNotesFile = "CHANGELOG.md" |
| 144 | + websiteUrl = repoWeb |
| 145 | + issueTrackerUrl = "$repoWeb/issues" |
| 146 | + vcsUrl = repoVcs |
| 147 | + setLicenses(licenseId) |
| 148 | + setLabels(*tags.toTypedArray()) |
| 149 | + version(delegateClosureOf<VersionConfig> { |
| 150 | + name = project.version.toString() |
| 151 | + vcsTag = releaseTag |
| 152 | + mavenCentralSync(delegateClosureOf<MavenCentralSyncConfig> { |
| 153 | + sync = project.properties["sonatype.user"] != null |
| 154 | + user = project.properties["sonatype.user"]?.toString() |
| 155 | + password = project.properties["sonatype.password"]?.toString() |
| 156 | + close = "true" |
| 157 | + }) |
| 158 | + }) |
| 159 | + }) |
| 160 | +} |
| 161 | + |
| 162 | +/** |
| 163 | + * Helper DSL to define Pom |
| 164 | + */ |
| 165 | +class NodeScope(private val node: Node, block: NodeScope.() -> Unit) { |
| 166 | + init { |
| 167 | + block() |
| 168 | + } |
| 169 | + infix fun String.to(value: String) { |
| 170 | + node.appendNode(this, value) |
| 171 | + } |
| 172 | + operator fun String.invoke(block: NodeScope.() -> Unit) { |
| 173 | + node.appendNode(this).apply { NodeScope(this, block) } |
| 174 | + } |
| 175 | +} |
0 commit comments