diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-01-31 00:37:29 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-01-31 15:27:26 +0100 |
commit | e99be615ce7c2c2b5c3ee5e3f8941c41c1e7a944 (patch) | |
tree | 7e3eb4f67d36d3b7b6db6aec08c58de2e1b678d3 /buildSrc/src/main/kotlin/org | |
parent | 0073c4c547dafaae5d465d4c410a52fd7fdc818d (diff) | |
download | dokka-e99be615ce7c2c2b5c3ee5e3f8941c41c1e7a944.tar.gz dokka-e99be615ce7c2c2b5c3ee5e3f8941c41c1e7a944.tar.bz2 dokka-e99be615ce7c2c2b5c3ee5e3f8941c41c1e7a944.zip |
Bump Gradle version, migrate to Kotlin DSL, refactor publishing
Diffstat (limited to 'buildSrc/src/main/kotlin/org')
3 files changed, 76 insertions, 0 deletions
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt b/buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt new file mode 100644 index 00000000..19e032a8 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt @@ -0,0 +1,29 @@ +package org.jetbrains + +import com.jfrog.bintray.gradle.BintrayExtension +import org.gradle.api.Project +import org.gradle.kotlin.dsl.provideDelegate + +fun Project.configureBintrayPublication(publication: String) = configureBintrayPublication(listOf(publication)) + +fun Project.configureBintrayPublication(publications: List<String>) { + val dokka_version: String by this + val dokka_publication_channel: String by this + extensions.configure<BintrayExtension>("bintray") { + user = System.getenv("BINTRAY_USER") + key = System.getenv("BINTRAY_KEY") + + pkg = PackageConfig().apply { + repo = dokka_publication_channel + name = "dokka" + userOrg = "kotlin" + desc = "Dokka, the Kotlin documentation tool" + vcsUrl = "https://github.com/kotlin/dokka.git" + setLicenses("Apache-2.0") + version = VersionConfig().apply { + name = dokka_version + } + } + setPublications(*publications.toTypedArray()) + } +}
\ No newline at end of file diff --git a/buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt b/buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt new file mode 100644 index 00000000..ec536bd7 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/DistMavenPublishing.kt @@ -0,0 +1,28 @@ +package org.jetbrains + +import org.gradle.api.Project +import org.gradle.api.artifacts.repositories.MavenArtifactRepository +import org.gradle.api.publish.PublishingExtension +import org.gradle.api.publish.maven.tasks.PublishToMavenRepository + +fun Project.configureDistMaven() { // TODO: This can probably be written cleaner + val repoLocation = uri(file("${rootProject.buildDir}/dist-maven")) + var distMaven: MavenArtifactRepository? = null + pluginManager.withPlugin("maven-publish") { + this@configureDistMaven.extensions.findByType(PublishingExtension::class.java)?.let { + it.repositories { + distMaven = maven { + name = "distMaven" + url = repoLocation + } + } + } + } + tasks.register("publishToDistMaven") { + group = "publishing" + description = "Publishes all Maven publications to Maven repository 'distMaven'" + dependsOn(tasks.withType(PublishToMavenRepository::class.java).matching { + it.repository == distMaven + }) + } +}
\ No newline at end of file diff --git a/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt b/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt new file mode 100644 index 00000000..5bd35415 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt @@ -0,0 +1,19 @@ +package org.jetbrains + +import org.gradle.api.Project +import org.gradle.kotlin.dsl.extra +import org.gradle.kotlin.dsl.provideDelegate + +fun Project.configureDokkaVersion(): String { + var dokka_version: String? by this.extra + if (dokka_version == null) { + val buildNumber = System.getenv("BUILD_NUMBER") + val dokka_version_base: String by this + dokka_version = dokka_version_base + if (buildNumber == null || System.getenv("FORCE_SNAPSHOT") != null) { + "-SNAPSHOT" + } else { + "-$buildNumber" + } + } + return dokka_version!! +}
\ No newline at end of file |