Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix publishing #127

Merged
merged 3 commits into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,14 @@ tasks.register("publishLocal") {
)
}

val publishToSonatype by tasks.registering {
group = "publishing"
}

tasks.named("closeRepository") {
mustRunAfter(publishToSonatype)
mustRunAfter("publishToSonatype")
}

tasks.register("publishToSonatypeAndRelease") {
group = "publishing"

dependsOn(publishToSonatype, "closeAndReleaseRepository")
dependsOn("publishToSonatype", "closeAndReleaseRepository")
}

tasks.register("publishToPluginPortal") {
Expand Down
3 changes: 0 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,5 @@ baseVersion=0.8.3
projectRepoUrl=https://github.com/Kotlin/kotlin-jupyter
docsRepo=git@github.com:ileasile/kotlin-jupyter-docs.git

bintray_user_org=kotlin
bintray_repo=kotlin-datascience

# Workaround for https://github.com/Kotlin/dokka/issues/1405
org.gradle.jvmargs=-XX:MaxMetaspaceSize=768m -Xmx2048m
4 changes: 2 additions & 2 deletions jupyter-lib/api-annotations/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ tasks.withType(KotlinCompile::class.java).all {
addPublication {
publicationName = "api-annotations"
artifactId = "kotlin-jupyter-api-annotations"
bintrayDescription = "Annotations for adding Kotlin Jupyter notebooks support to Kotlin libraries"
bintrayPackageName = artifactId
description = "Annotations for adding Kotlin Jupyter notebooks support to Kotlin libraries"
packageName = artifactId
}
4 changes: 2 additions & 2 deletions jupyter-lib/api-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pluginBundle {
addPublication {
publicationName = pluginName
artifactId = "kotlin-jupyter-api-gradle-plugin"
bintrayDescription = "Gradle plugin providing a smooth Jupyter notebooks integration for Kotlin libraries"
bintrayPackageName = artifactId
description = "Gradle plugin providing a smooth Jupyter notebooks integration for Kotlin libraries"
packageName = artifactId
publishToSonatype = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.jetbrains.kotlinx.jupyter.api.plugin
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.invoke
import org.gradle.kotlin.dsl.maven
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.repositories
import org.jetbrains.kotlin.gradle.internal.Kapt3GradleSubplugin
Expand All @@ -24,7 +23,6 @@ class ApiGradlePlugin : Plugin<Project> {

target.repositories {
mavenCentral()
maven("https://kotlin.bintray.com/kotlin-datascience")
}

val pluginExtension = KotlinJupyterPluginExtension(target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ open class JupyterApiResourcesTask : DefaultTask() {
)
}

class FQNAware(
data class FQNAware(
val fqn: String
)

Expand All @@ -77,8 +77,17 @@ open class JupyterApiResourcesTask : DefaultTask() {

operator fun LibrariesScanResult.plus(other: LibrariesScanResult): LibrariesScanResult {
return LibrariesScanResult(
definitions + other.definitions,
producers + other.producers
union(definitions, other.definitions),
union(producers, other.producers)
)
}

companion object {
private inline fun <reified T> union(a: Array<T>, b: Array<T>): Array<T> {
val result = mutableSetOf<T>()
result.addAll(a)
result.addAll(b)
return result.toTypedArray()
}
}
}
4 changes: 2 additions & 2 deletions jupyter-lib/api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ tasks {
addPublication {
publicationName = "api"
artifactId = "kotlin-jupyter-api"
bintrayDescription = "API for libraries supporting Kotlin Jupyter notebooks"
bintrayPackageName = artifactId
description = "API for libraries supporting Kotlin Jupyter notebooks"
packageName = artifactId
}
4 changes: 2 additions & 2 deletions jupyter-lib/lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ dependencies {
addPublication {
publicationName = "lib"
artifactId = "kotlin-jupyter-lib"
bintrayDescription = "Internal part of Kotlin Jupyter API used only inside notebook cells"
bintrayPackageName = artifactId
description = "Internal part of Kotlin Jupyter API used only inside notebook cells"
packageName = artifactId
}
4 changes: 2 additions & 2 deletions jupyter-lib/shared-compiler/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ tasks.processResources {
addPublication {
publicationName = "compiler"
artifactId = "kotlin-jupyter-shared-compiler"
bintrayDescription = "Implementation of REPL compiler and preprocessor for Jupyter dialect of Kotlin (IDE-compatible)"
bintrayPackageName = artifactId
description = "Implementation of REPL compiler and preprocessor for Jupyter dialect of Kotlin (IDE-compatible)"
packageName = artifactId
}
4 changes: 2 additions & 2 deletions kotlin-jupyter-plugin/common-dependencies/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ dependencies {
addPublication {
publicationName = "common-dependencies"
artifactId = "kotlin-jupyter-common-dependencies"
bintrayDescription = "Notebook API entities used for building kernel documentation"
bintrayPackageName = artifactId
description = "Notebook API entities used for building kernel documentation"
packageName = artifactId
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ fun ProjectWithOptions.prepareAggregateUploadTasks() {

tasksList.add("publishToPluginPortal")
tasksList.add("publishToSonatypeAndRelease")
tasksList.add("bintrayUpload")
tasksList.add("publishDocs")

tasks.register("aggregate${infix}Upload") {
Expand Down
2 changes: 1 addition & 1 deletion kotlin-jupyter-publish/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ repositories {
}

dependencies {
implementation("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.20")
implementation("io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.22.0")
implementation("de.marcphilipp.gradle:nexus-publish-plugin:0.4.0")

// For maven-publish
implementation(gradleApi())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jetbrains.kotlinx.jupyter.plugin

import com.jfrog.bintray.gradle.BintrayPlugin
import de.marcphilipp.gradle.nexus.NexusPublishPlugin
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
Expand All @@ -12,7 +12,7 @@ class ApiPublishGradlePlugin : Plugin<Project> {
target.pluginManager.run {
apply(DokkaPlugin::class.java)
apply(MavenPublishPlugin::class.java)
apply(BintrayPlugin::class.java)
apply(NexusPublishPlugin::class.java)
apply(SigningPlugin::class.java)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ArtifactPublication {
var publicationName: String? = null
var artifactId: String? = null
var groupId: String? = NEXUS_PACKAGE_GROUP
var bintrayPackageName: String? = null
var bintrayDescription: String? = null
var packageName: String? = null
var description: String? = null
var publishToSonatype: Boolean = true
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jetbrains.kotlinx.jupyter.publishing

import de.marcphilipp.gradle.nexus.NexusPublishExtension
import de.marcphilipp.gradle.nexus.NexusPublishPlugin
import io.codearte.gradle.nexus.NexusStagingExtension
import io.codearte.gradle.nexus.NexusStagingPlugin
import org.gradle.api.Project
Expand All @@ -15,16 +17,29 @@ fun getNexusPassword(): String? {
return System.getenv("SONATYPE_PASSWORD")
}

fun Project.configureNexusPublish() {
extensions.configure<NexusPublishExtension>("nexusPublishing") {
repositories {
sonatype {
username.set(getNexusUser())
password.set(getNexusPassword())
}
}
}
}

fun Project.applyNexusPlugin() {
pluginManager.run {
apply(NexusStagingPlugin::class.java)
apply(NexusPublishPlugin::class.java)
}

extensions.configure<NexusStagingExtension>("nexusStaging") {
username = getNexusUser()
password = getNexusPassword()
packageGroup = NEXUS_PACKAGE_GROUP
repositoryDescription = "kotlin-jupyter project, v. ${project.version}"
// serverUrl = NEXUS_REPO_URL
}

configureNexusPublish()
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package org.jetbrains.kotlinx.jupyter.publishing

import com.jfrog.bintray.gradle.BintrayExtension
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.delegateClosureOf
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.getByName
import org.gradle.kotlin.dsl.invoke
import org.gradle.plugins.signing.SigningExtension
import org.jetbrains.dokka.gradle.DokkaTask
import java.io.File
import java.net.URI
import java.nio.file.Path
import java.util.Date

fun Project.addPublication(configuration: ArtifactPublication.() -> Unit) {
val settings = ArtifactPublication().apply(configuration)
Expand All @@ -24,8 +20,6 @@ fun Project.addPublication(configuration: ArtifactPublication.() -> Unit) {
val mainSourceSet = sourceSets.named("main").get()
val publicationName = settings.publicationName!!

val sonatypeUser = getNexusUser()
val sonatypePassword = getNexusPassword()
val signingPrivateKey = System.getenv("SIGN_KEY_PRIVATE")
val signingKey = System.getenv("SIGN_KEY_ID")
val signingKeyPassphrase = System.getenv("SIGN_KEY_PASSPHRASE")
Expand Down Expand Up @@ -68,8 +62,8 @@ fun Project.addPublication(configuration: ArtifactPublication.() -> Unit) {
artifact(tasks["javadocJar"])

pom {
name.set(settings.bintrayPackageName)
description.set(settings.bintrayDescription)
name.set(settings.packageName)
description.set(settings.description)
url.set("https://github.com/Kotlin/kotlin-jupyter")
inceptionYear.set("2021")

Expand Down Expand Up @@ -111,60 +105,11 @@ fun Project.addPublication(configuration: ArtifactPublication.() -> Unit) {
url = it.toUri()
}
}

maven {
name = "Sonatype"
url = URI(NEXUS_REPO_URL)
credentials {
username = sonatypeUser
password = sonatypePassword
}
}
}
}

extensions.configure<BintrayExtension>("bintray") {
// property must be set in ~/.gradle/gradle.properties
user = project.findProperty("bintray_user") as String? ?: ""
key = project.findProperty("bintray_key") as String? ?: ""
val bintrayRepo = project.findProperty("bintray_repo") as String? ?: ""
val bintrayUserOrg = project.findProperty("bintray_user_org") as String? ?: ""

setPublications(settings.publicationName) // When uploading configuration files

dryRun = false // Whether to run this as dry-run, without deploying
publish = true // If version should be auto published after an upload

pkg(
delegateClosureOf<BintrayExtension.PackageConfig> {
repo = bintrayRepo
name = settings.bintrayPackageName
userOrg = bintrayUserOrg
desc = settings.bintrayDescription

val projectUrl = project.findProperty("projectRepoUrl") as String? ?: ""
websiteUrl = projectUrl
vcsUrl = projectUrl
issueTrackerUrl = "$projectUrl/issues"

setLicenses("Apache-2.0")
publicDownloadNumbers = true

// Optional version descriptor
version(
delegateClosureOf<BintrayExtension.VersionConfig> {
val projVersion = project.version as String
name = projVersion // Bintray logical version name
desc = settings.bintrayDescription
released = Date().toString()
vcsTag = projVersion
}
)
}
)
}

val thisProjectName = project.name
val thisProject = project

if (rootProject.findProperty("isMainProject") == true) {
rootProject.tasks {
Expand All @@ -173,8 +118,9 @@ fun Project.addPublication(configuration: ArtifactPublication.() -> Unit) {
}

if (settings.publishToSonatype) {
thisProject.configureNexusPublish()
named("publishToSonatype") {
dependsOn(":$thisProjectName:publishAllPublicationsToSonatypeRepository")
dependsOn(":$thisProjectName:publishToSonatype")
}
}
}
Expand Down