Skip to content

Commit

Permalink
publish to maven central directly
Browse files Browse the repository at this point in the history
issue #177
using signing and publish plugin:
https://github.com/gradle-nexus/publish-plugin
  • Loading branch information
oshai committed Jun 1, 2021
1 parent de54a65 commit 521518c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 82 deletions.
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ dist: trusty

stages:
- name: build
- name: snapshot
if: branch IN (master, pre-snapshot, 1.x-snapshot) AND type = push
- name: release
if: branch IN (release, 1.x) AND type = push
if: branch IN (release) AND type = push

jobs:
include:
- stage: build
script: ./gradlew clean build
- stage: snapshot
script: ./gradlew clean build artifactoryPublish -Dsnapshot=true -Dbintray.user=$BINTRAY_USER -Dbintray.key=$BINTRAY_API_KEY -Dbuild.number=$TRAVIS_BUILD_NUMBER
- stage: release
script: ./gradlew clean build publishAllPublicationsToBintrayRepository -Dbintray.user=$BINTRAY_USER -Dbintray.key=$BINTRAY_API_KEY -Dbuild.number=$TRAVIS_BUILD_NUMBER -Dmaven.password=$MAVEN_PASSWORD -Dmaven.user=$MAVEN_USER
script: ./gradlew clean build publishToSonatype closeAndReleaseSonatypeStagingRepository -no-daemon --no-parallel -x test
94 changes: 18 additions & 76 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
plugins {
kotlin("multiplatform") version "1.4.31"
id("org.jetbrains.dokka") version "1.4.0"
id("com.jfrog.artifactory") version "4.17.2"
`maven-publish`
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
signing
}

apply("versions.gradle.kts")

group = "io.github.microutils"
version = "2.0.8" + (if (System.getProperty("snapshot")?.toBoolean() == true) "-SNAPSHOT" else "")
version = "2.0.8"

repositories {
jcenter()
mavenCentral()
}

nexusPublishing {
repositories {
sonatype()
}
}

apply(plugin = "io.github.gradle-nexus.publish-plugin")
apply(plugin = "maven-publish")
apply(plugin = "signing")

kotlin {
explicitApi()
jvm {
Expand Down Expand Up @@ -124,77 +134,9 @@ publishing {
}
}

publishing {
val bintrayOrg = "microutils"
val bintrayRepo = "kotlin-logging"
val bintrayUser = System.getProperty("bintray.user")
val bintrayApiKey = System.getProperty("bintray.key")

if (bintrayUser != null && bintrayApiKey != null) {
repositories {
maven {
name = "bintray"
url = uri(
"https://api.bintray.com/maven/$bintrayOrg/$bintrayRepo/${project.name}/;publish=1;override=1"
)
credentials {
username = bintrayUser
password = bintrayApiKey
}
}
}
}
}

//bintray {
// user = System.getProperty("bintray.user")
// key = System.getProperty("bintray.key") //https://bintray.com/profile/edit
// setPublications(*publishing.publications.names.toTypedArray())
// publish = true //[Default: false] Whether version should be auto published after an upload
// pkg.apply {
// repo = "kotlin-logging"
// name = "kotlin-logging"
// userOrg = "microutils"
// setLicenses("Apache-2.0")
// vcsUrl = "https://github.com/MicroUtils/kotlin-logging"
// websiteUrl = "https://github.com/MicroUtils/kotlin-logging"
// issueTrackerUrl = "https://github.com/MicroUtils/kotlin-logging/issues"
//
// githubRepo = "MicroUtils/kotlin-logging"
// githubReleaseNotesFile = "ChangeLog.md"
// version.apply {
// name = "${project.version}"
// desc = "kotlin-logging - Lightweight logging framework for Kotlin"
// released = "${Date()}"
// gpg.sign = true //Determines whether to GPG sign the files. The default is false
// mavenCentralSync.apply {
// sync = true //[Default: true] Determines whether to sync the version to Maven Central.
// user = System.getProperty("maven.user") //OSS user token: mandatory
// password = System.getProperty("maven.password") //OSS user password: mandatory
// close =
// "1" //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
// }
// }
// }
//}

artifactory {
setContextUrl("http://oss.jfrog.org")
publish(delegateClosureOf<org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig> {
repository(delegateClosureOf<groovy.lang.GroovyObject> {
setProperty("repoKey", "oss-snapshot-local")
setProperty("username", System.getProperty("bintray.user"))
setProperty("password", System.getProperty("bintray.key"))
setProperty("maven", true)
})
defaults(delegateClosureOf<groovy.lang.GroovyObject> {
invokeMethod("publications", publishing.publications.names.toTypedArray())
setProperty("publishArtifacts", true)
setProperty("publishPom", true)
})
})
resolve(delegateClosureOf<org.jfrog.gradle.plugin.artifactory.dsl.ResolverConfig> {
setProperty("repoKey", "jcenter")
})
clientConfig.info.buildNumber = System.getProperty("build.number")
signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications["mavenJava"])
}

0 comments on commit 521518c

Please sign in to comment.