|
| 1 | +@file:Suppress("UNUSED_VARIABLE", "HasPlatformType") |
| 2 | + |
| 3 | +import org.gradle.api.publish.maven.MavenPom |
| 4 | +import org.jetbrains.dokka.gradle.DokkaTask |
| 5 | + |
| 6 | +buildscript { |
| 7 | + repositories { |
| 8 | + jcenter() |
| 9 | + } |
| 10 | +} |
| 11 | + |
| 12 | +plugins { |
| 13 | + id("java-library") |
| 14 | + kotlin("jvm") version "1.3.40" |
| 15 | + id("org.jetbrains.dokka") version "0.9.18" |
| 16 | + id("maven-publish") |
| 17 | + id("com.jfrog.bintray") version "1.8.4" |
| 18 | +} |
| 19 | + |
| 20 | +repositories { |
| 21 | + jcenter() |
| 22 | +} |
| 23 | + |
| 24 | +group = "io.reactivex.rxjava2" |
| 25 | + |
| 26 | +//additional source sets |
| 27 | +sourceSets { |
| 28 | + val examples by creating { |
| 29 | + java { |
| 30 | + compileClasspath += sourceSets.main.get().output |
| 31 | + runtimeClasspath += sourceSets.main.get().output |
| 32 | + } |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +//examples configuration |
| 37 | +val examplesImplementation by configurations.getting { |
| 38 | + extendsFrom(configurations.implementation.get()) |
| 39 | +} |
| 40 | + |
| 41 | +dependencies { |
| 42 | + implementation("io.reactivex.rxjava2:rxjava:2.2.10") |
| 43 | + implementation(kotlin("stdlib")) |
| 44 | + |
| 45 | + testImplementation("org.funktionale:funktionale-partials:1.0.0-final") |
| 46 | + testImplementation("junit:junit:4.12") |
| 47 | + testImplementation("org.mockito:mockito-core:1.10.19") |
| 48 | + |
| 49 | + examplesImplementation("com.squareup.retrofit2:retrofit:2.6.0") |
| 50 | + examplesImplementation("com.squareup.retrofit2:adapter-rxjava2:2.6.0") |
| 51 | + examplesImplementation("com.squareup.retrofit2:converter-moshi:2.6.0") |
| 52 | +} |
| 53 | + |
| 54 | +//sources |
| 55 | +val sourcesJar by tasks.creating(Jar::class) { |
| 56 | + from(sourceSets.main.get().allSource) |
| 57 | + archiveClassifier.set("sources") |
| 58 | +} |
| 59 | + |
| 60 | +//documentation |
| 61 | +val dokka by tasks.getting(DokkaTask::class) { |
| 62 | + outputFormat = "html" |
| 63 | + outputDirectory = "$buildDir/javadoc" |
| 64 | + |
| 65 | +} |
| 66 | + |
| 67 | +//documentation |
| 68 | +val dokkaJavadoc by tasks.creating(DokkaTask::class) { |
| 69 | + outputFormat = "javadoc" |
| 70 | + outputDirectory = "$buildDir/javadoc" |
| 71 | +} |
| 72 | + |
| 73 | +//documentation |
| 74 | +val javadocJar by tasks.creating(Jar::class) { |
| 75 | + dependsOn(dokkaJavadoc) |
| 76 | + archiveClassifier.set("javadoc") |
| 77 | + from("$buildDir/javadoc") |
| 78 | +} |
| 79 | + |
| 80 | +//publications |
| 81 | +val snapshot = "snapshot" |
| 82 | +val release = "release" |
| 83 | + |
| 84 | +publishing { |
| 85 | + |
| 86 | + fun MavenPom.initPom() { |
| 87 | + name.set("RxKotlin") |
| 88 | + description.set("RxJava bindings for Kotlin") |
| 89 | + url.set("https://github.com/ReactiveX/RxKotlin") |
| 90 | + |
| 91 | + licenses { |
| 92 | + license { |
| 93 | + name.set("The Apache License, Version 2.0") |
| 94 | + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") |
| 95 | + } |
| 96 | + } |
| 97 | + scm { |
| 98 | + url.set("https://github.com/ReactiveX/RxKotlin.git") |
| 99 | + } |
| 100 | + } |
| 101 | + |
| 102 | + publications { |
| 103 | + create<MavenPublication>(snapshot) { |
| 104 | + artifactId = "rxkotlin" |
| 105 | + version = "${project.version}-SNAPSHOT" |
| 106 | + |
| 107 | + from(components["java"]) |
| 108 | + |
| 109 | + pom.initPom() |
| 110 | + } |
| 111 | + create<MavenPublication>(release) { |
| 112 | + artifactId = "rxkotlin" |
| 113 | + version = "${project.version}" |
| 114 | + |
| 115 | + from(components["java"]) |
| 116 | + artifact(sourcesJar) |
| 117 | + artifact(javadocJar) |
| 118 | + |
| 119 | + pom.initPom() |
| 120 | + } |
| 121 | + } |
| 122 | +} |
| 123 | + |
| 124 | +bintray { |
| 125 | + user = project.findProperty("bintrayUser") as? String |
| 126 | + key = project.findProperty("bintrayKey") as? String |
| 127 | + |
| 128 | + val isRelease = project.findProperty("release") == "true" |
| 129 | + |
| 130 | + publish = isRelease |
| 131 | + override = false |
| 132 | + |
| 133 | + setPublications(if (isRelease) release else snapshot) |
| 134 | + |
| 135 | +// dryRun = true |
| 136 | + |
| 137 | + with(pkg) { |
| 138 | + userOrg = "reactivex" |
| 139 | + repo = "RxJava" |
| 140 | + name = "RxKotlin" |
| 141 | + setLicenses("Apache-2.0") |
| 142 | + setLabels("reactivex", "rxjava", "rxkotlin") |
| 143 | + websiteUrl = "https://github.com/ReactiveX/RxKotlin" |
| 144 | + issueTrackerUrl = "https://github.com/ReactiveX/RxKotlin/issues" |
| 145 | + vcsUrl = "https://github.com/ReactiveX/RxKotlin.git" |
| 146 | + |
| 147 | + with(version) { |
| 148 | + name = project.version.toString() |
| 149 | + vcsTag = project.version.toString() |
| 150 | + |
| 151 | + with(gpg){ |
| 152 | + sign = true |
| 153 | + } |
| 154 | + |
| 155 | + with(mavenCentralSync) { |
| 156 | + sync = true |
| 157 | + user = project.findProperty("sonatypeUsername") as? String |
| 158 | + password = project.findProperty("sonatypePassword") as? String |
| 159 | + close = "1" |
| 160 | + } |
| 161 | + } |
| 162 | + } |
| 163 | +} |
0 commit comments