From 4078fcd5c2bb237c1bc45cc1835ca7a212b87a55 Mon Sep 17 00:00:00 2001 From: Ranie Jade Ramiso Date: Sun, 14 Feb 2021 14:25:28 +1100 Subject: [PATCH] Publish to maven central (#951) --- .github/workflows/ci.yaml | 12 ++-- README.md | 4 +- build.gradle.kts | 2 + buildSrc/src/main/kotlin/publish.gradle.kts | 57 ++++++++++++------- docs/index.md | 6 +- gradle/common/dependencies.gradle | 39 ------------- gradle/common/idea-plugin.gradle | 19 ------- gradle/common/kotlin-common.gradle | 24 -------- gradle/common/kotlin-jvm.gradle | 28 --------- gradle/common/publish-plugin.gradle | 20 ------- gradle/common/publish.gradle | 42 -------------- gradle/common/versioning.gradle | 6 -- .../build.gradle.kts | 4 +- 13 files changed, 51 insertions(+), 212 deletions(-) delete mode 100644 gradle/common/dependencies.gradle delete mode 100644 gradle/common/idea-plugin.gradle delete mode 100644 gradle/common/kotlin-common.gradle delete mode 100644 gradle/common/kotlin-jvm.gradle delete mode 100644 gradle/common/publish-plugin.gradle delete mode 100644 gradle/common/publish.gradle delete mode 100644 gradle/common/versioning.gradle diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 58ce372db..4c89c3e51 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,11 +15,11 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] include: - os: ubuntu-latest - arguments: spek-dsl:bintrayUpload spek-runtime:bintrayUpload spek-runner-junit5:bintrayUpload --stacktrace -PexcludeIdePlugins + arguments: spek-dsl:publish spek-runtime:publish spek-runner-junit5:publish --stacktrace -PexcludeIdePlugins - os: windows-latest - arguments: spek-dsl:bintrayUpload spek-runtime:bintrayUpload --stacktrace -PexcludeIdePlugins + arguments: spek-dsl:publish spek-runtime:publish --stacktrace -PexcludeIdePlugins - os: macos-latest - arguments: spek-dsl:bintrayUpload spek-runtime:bintrayUpload --stacktrace -PexcludeIdePlugins + arguments: spek-dsl:publish spek-runtime:publish --stacktrace -PexcludeIdePlugins runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 @@ -36,8 +36,10 @@ jobs: with: arguments: ${{ matrix.arguments }} env: - BINTRAY_USER: ${{ secrets.BINTRAY_USER }} - BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }} + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + OSSRH_SIGNING_KEY: ${{ secrets.OSSRH_SIGNING_KEY }} + OSSRH_SIGNING_PASSWORD: ${{ secrets.OSSRH_SIGNING_PASSWORD }} deploy_ij_plugin: strategy: diff --git a/README.md b/README.md index 2877a9438..61c2949be 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/spekframework/spek/CI?style=flat-square)](https://github.com/spekframework/spek/actions?query=workflow%3ACI) -[ ![Download](https://img.shields.io/badge/dynamic/json.svg?label=stable&url=https%3A%2F%2Fapi.bintray.com%2Fpackages%2Fspekframework%2Fspek%2Fspek2%2Fversions%2F_latest&query=name&colorB=blue) ](https://bintray.com/spekframework/spek/spek2/_latestVersion) -[ ![Download](https://img.shields.io/badge/dynamic/json.svg?label=dev&url=https%3A%2F%2Fapi.bintray.com%2Fpackages%2Fspekframework%2Fspek-dev%2Fspek2%2Fversions%2F_latest&query=name&colorB=blue) ](https://bintray.com/spekframework/spek-dev/spek2/_latestVersion) +![Maven Central](https://img.shields.io/maven-central/v/org.spekframework.spek2/spek-dsl-jvm?style=flat-square) +![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/org.spekframework.spek2/spek-dsl-jvm?server=https%3A%2F%2Foss.sonatype.org&style=flat-square) ![Spek Logo](spek-logo.png) diff --git a/build.gradle.kts b/build.gradle.kts index 98918ea2e..a98a05509 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -27,6 +27,8 @@ allprojects { var releaseMode = false if ("$version".matches(Regex("^\\d+\\.\\d+\\.\\d+(-rc\\.\\d+)?"))) { releaseMode = true + } else { + version = "$version-SNAPSHOT" } project.extra["releaseMode"] = releaseMode diff --git a/buildSrc/src/main/kotlin/publish.gradle.kts b/buildSrc/src/main/kotlin/publish.gradle.kts index 64e7d5d98..c2701ef84 100644 --- a/buildSrc/src/main/kotlin/publish.gradle.kts +++ b/buildSrc/src/main/kotlin/publish.gradle.kts @@ -1,42 +1,55 @@ plugins { - id("com.jfrog.bintray") - `maven-publish` apply false + `maven-publish` + signing } -val bintrayUser = propOrEnv("BINTRAY_USER") -val bintrayApiKey = propOrEnv("BINTRAY_API_KEY") - var bintrayRepo = "spek-dev" var doPublish = true +var releaseMode = project.extra["releaseMode"] == true + if (project.extra["releaseMode"] == true) { bintrayRepo = "spek" doPublish = false } -val artifacts = project.extra["artifacts"] as Array -bintray { - user = bintrayUser - key = bintrayApiKey - publish = doPublish - with(pkg) { - repo = bintrayRepo - desc = "Test framework for Kotlin" - name = "spek2" - userOrg = "spekframework" - setLicenses("BSD New") - setLabels("kotlin", "testing") - vcsUrl = "https://github.com/spekframework/spek.git" - githubRepo = "spekframework/spek" - with(version) { - name = rootProject.version.toString() +val artifacts = (project.extra["artifacts"] as Array).toHashSet() + +tasks.withType() + .configureEach { + onlyIf { + artifacts.contains(publication.name) } } - setPublications(*artifacts) +signing { + val signingKey = propOrEnv("OSSRH_SIGNING_KEY") + val signingPassword = propOrEnv("OSSRH_SIGNING_PASSWORD") + useInMemoryPgpKeys(signingKey, signingPassword) + publishing.publications.all { + if (artifacts.contains(name)) { + sign(this) + } + } } publishing { + repositories { + maven { + val targetRepo = if (releaseMode) { + "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + } else { + "https://oss.sonatype.org/content/repositories/snapshots/" + } + setUrl(targetRepo) + + credentials { + username = propOrEnv("OSSRH_USERNAME") + password = propOrEnv("OSSRH_PASSWORD") + } + } + } + publications { all { if (this is MavenPublication) { diff --git a/docs/index.md b/docs/index.md index 379739a49..797de6947 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,6 @@ -[ ![CI](https://travis-ci.com/spekframework/spek.svg?branch=2.x) ](https://travis-ci.com/spekframework/spek) -[ ![Download](https://img.shields.io/badge/dynamic/json.svg?label=stable&url=https%3A%2F%2Fapi.bintray.com%2Fpackages%2Fspekframework%2Fspek%2Fspek2%2Fversions%2F_latest&query=name&colorB=blue) ](https://bintray.com/spekframework/spek/spek2/_latestVersion) -[ ![Download](https://img.shields.io/badge/dynamic/json.svg?label=dev&url=https%3A%2F%2Fapi.bintray.com%2Fpackages%2Fspekframework%2Fspek-dev%2Fspek2%2Fversions%2F_latest&query=name&colorB=blue) ](https://bintray.com/spekframework/spek-dev/spek2/_latestVersion) +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/spekframework/spek/CI?style=flat-square)](https://github.com/spekframework/spek/actions?query=workflow%3ACI) +![Maven Central](https://img.shields.io/maven-central/v/org.spekframework.spek2/spek-dsl-jvm?style=flat-square) +![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/org.spekframework.spek2/spek-dsl-jvm?server=https%3A%2F%2Foss.sonatype.org&style=flat-square) Spek `2.x` is a complete rewrite of Spek with Kotlin multiplatform support in mind. The DSL is also reworked into two distinct styles: [specification](specification.md) and [gherkin](gherkin.md). diff --git a/gradle/common/dependencies.gradle b/gradle/common/dependencies.gradle deleted file mode 100644 index 0182f6b72..000000000 --- a/gradle/common/dependencies.gradle +++ /dev/null @@ -1,39 +0,0 @@ -allprojects { - afterEvaluate { project -> - // By applying the constraint to the implementation configuration, the contraint will filter down to - // all other configurations. See https://github.com/gradle/gradle/issues/7576 for details. - def mainConfigurationName = (project.configurations.names.contains("commonMainImplementation")) ? "commonMainImplementation" : "implementation" - - dependencies { - constraints { - add(mainConfigurationName, 'com.natpryce:hamkrest:1.1.0.0') - - add(mainConfigurationName, "org.junit.platform:junit-platform-engine:$junitPlatformVersion") - add(mainConfigurationName, "org.junit.platform:junit-platform-runner:$junitPlatformVersion") - add(mainConfigurationName, "org.junit.platform:junit-platform-launcher:$junitPlatformVersion") - - add(mainConfigurationName, "org.junit.jupiter:junit-jupiter-api:5.0.1") - add(mainConfigurationName, "org.junit.jupiter:junit-jupiter-engine:5.0.1") - add(mainConfigurationName, "org.junit.jupiter:junit-jupiter-launcher:5.0.1") - - add(mainConfigurationName, "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion") - add(mainConfigurationName, "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlinVersion") - add(mainConfigurationName, "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion") - add(mainConfigurationName, "org.jetbrains.kotlin:kotlin-test:$kotlinVersion") - add(mainConfigurationName, "org.jetbrains.kotlin:kotlin-common:$kotlinVersion") - - add(mainConfigurationName, 'io.github.classgraph:classgraph:4.8.37') - - add(mainConfigurationName, 'com.xenomachina:kotlin-argparser:2.0.6') - - add(mainConfigurationName, 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.0.0') - - add(mainConfigurationName, 'org.mockito:mockito-core:2.23.4') - add(mainConfigurationName, 'org.mockito:mockito-inline:2.23.4') - add(mainConfigurationName, 'org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.2.1') - add(mainConfigurationName, 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1') - add(mainConfigurationName, 'org.jetbrains.kotlinx:kotlinx-coroutines-native:1.2.1') - } - } - } -} diff --git a/gradle/common/idea-plugin.gradle b/gradle/common/idea-plugin.gradle deleted file mode 100644 index e2c2ce404..000000000 --- a/gradle/common/idea-plugin.gradle +++ /dev/null @@ -1,19 +0,0 @@ -apply plugin: 'org.jetbrains.intellij' -apply plugin: 'kotlin-platform-jvm' - -intellij { - pluginName = 'Spek' - updateSinceUntilBuild = false - downloadSources = true -} - -dependencies { - compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" -} - -compileKotlin { - kotlinOptions { - jvmTarget = '1.8' - verbose = true - } -} diff --git a/gradle/common/kotlin-common.gradle b/gradle/common/kotlin-common.gradle deleted file mode 100644 index df1f621a2..000000000 --- a/gradle/common/kotlin-common.gradle +++ /dev/null @@ -1,24 +0,0 @@ -apply plugin: 'kotlin-platform-common' -//apply plugin: 'org.jetbrains.dokka' - -def archiveBaseName = "${project.parent.name}-${project.name}" - -dependencies { - compile 'org.jetbrains.kotlin:kotlin-stdlib-common' -} - -task sourceJar(type: Jar) { - baseName = archiveBaseName - from project.sourceSets.main.allSource - classifier "sources" -} - -task javadocJar(type: Jar /*, dependsOn: dokka */) { - baseName = archiveBaseName -// from dokka.outputDirectory - classifier = 'javadoc' -} - -jar { - baseName = archiveBaseName -} diff --git a/gradle/common/kotlin-jvm.gradle b/gradle/common/kotlin-jvm.gradle deleted file mode 100644 index 4ce645625..000000000 --- a/gradle/common/kotlin-jvm.gradle +++ /dev/null @@ -1,28 +0,0 @@ -apply plugin: 'kotlin-platform-jvm' -apply plugin: 'org.jetbrains.dokka' - -def archiveBaseName = "${project.parent.name}-${project.name}" - -dependencies { - compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' -} - -task sourceJar(type: Jar) { - baseName = archiveBaseName - from project.sourceSets.main.java - classifier "sources" -} - -task javadocJar(type: Jar, dependsOn: dokka) { - baseName = archiveBaseName - from dokka.outputDirectory - classifier = 'javadoc' -} - -compileKotlin { - kotlinOptions.jvmTarget = '1.8' -} - -jar { - baseName = archiveBaseName -} diff --git a/gradle/common/publish-plugin.gradle b/gradle/common/publish-plugin.gradle deleted file mode 100644 index 0854dd3de..000000000 --- a/gradle/common/publish-plugin.gradle +++ /dev/null @@ -1,20 +0,0 @@ -String propOrEnv(String name) { - String property = project.findProperty(name) - if (property == null) { - property = System.getenv(name) - } - return property -} - -def channel = 'dev' - -if (project.ext.releaseMode) { - channel = 'default' -} - -def publishToken = propOrEnv('HUB_API_TOKEN') - -publishPlugin { - token = publishToken - channels = [channel] -} \ No newline at end of file diff --git a/gradle/common/publish.gradle b/gradle/common/publish.gradle deleted file mode 100644 index 6ee96954d..000000000 --- a/gradle/common/publish.gradle +++ /dev/null @@ -1,42 +0,0 @@ -apply plugin: 'com.jfrog.bintray' - -String propOrEnv(String name) { - String property = project.findProperty(name) - if (property == null) { - property = System.getenv(name) - } - return property -} - -def bintrayUser = propOrEnv("BINTRAY_USER") -def bintrayApiKey = propOrEnv("BINTRAY_API_KEY") - -def bintrayRepo = 'spek-dev' -def doPublish = true - -if (project.ext.releaseMode) { - bintrayRepo = 'spek' - doPublish = false -} - -def artifacts = ext.artifacts -bintray { - user = bintrayUser - key = bintrayApiKey - publish = doPublish - pkg { - repo = bintrayRepo - desc = "Test framework for Kotlin" - name = 'spek2' - userOrg = 'spekframework' - licenses = ['BSD New'] - labels = ['kotlin', 'testing'] - vcsUrl = 'https://github.com/spekframework/spek.git' - githubRepo = 'spekframework/spek' - version { - name = rootProject.version - } - } - - publications = artifacts -} \ No newline at end of file diff --git a/gradle/common/versioning.gradle b/gradle/common/versioning.gradle deleted file mode 100644 index dbc3976cd..000000000 --- a/gradle/common/versioning.gradle +++ /dev/null @@ -1,6 +0,0 @@ -apply plugin: "org.ajoberstar.reckon" - -reckon { - scopeFromProp() - stageFromProp('alpha', 'rc', 'final') -} diff --git a/spek-ide-plugin-intellij-idea/build.gradle.kts b/spek-ide-plugin-intellij-idea/build.gradle.kts index 83b166bb2..c83a8e3fc 100644 --- a/spek-ide-plugin-intellij-idea/build.gradle.kts +++ b/spek-ide-plugin-intellij-idea/build.gradle.kts @@ -14,14 +14,14 @@ val buildMatrix = mapOf( arrayOf("java", "org.jetbrains.kotlin:1.3.50-release-IJ2019.2-1") ), "IJ201" to ij.BuildConfig( - "201-EAP-SNAPSHOT", + "201.8743.12", "IJ2020.1", "IJ183", ij.VersionRange("201.1", "201.*"), arrayOf("java", "org.jetbrains.kotlin:1.3.61-release-IJ2019.3-1") ), "IJ202" to ij.BuildConfig( - "202-EAP-SNAPSHOT", + "202.8194.7", "IJ2020.2", "IJ183", ij.VersionRange("202.1", "202.*"),