Skip to content

Commit bc4bb55

Browse files
authored
publish to maven central directly (#178)
issue #177 using signing and publish plugin: https://github.com/gradle-nexus/publish-plugin
1 parent de54a65 commit bc4bb55

File tree

2 files changed

+20
-82
lines changed

2 files changed

+20
-82
lines changed

.travis.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@ dist: trusty
77

88
stages:
99
- name: build
10-
- name: snapshot
11-
if: branch IN (master, pre-snapshot, 1.x-snapshot) AND type = push
1210
- name: release
13-
if: branch IN (release, 1.x) AND type = push
11+
if: branch IN (release) AND type = push
1412

1513
jobs:
1614
include:
1715
- stage: build
1816
script: ./gradlew clean build
19-
- stage: snapshot
20-
script: ./gradlew clean build artifactoryPublish -Dsnapshot=true -Dbintray.user=$BINTRAY_USER -Dbintray.key=$BINTRAY_API_KEY -Dbuild.number=$TRAVIS_BUILD_NUMBER
2117
- stage: release
22-
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
18+
script: ./gradlew clean build publishToSonatype closeAndReleaseSonatypeStagingRepository -no-daemon --no-parallel -x test

build.gradle.kts

Lines changed: 18 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
plugins {
22
kotlin("multiplatform") version "1.4.31"
33
id("org.jetbrains.dokka") version "1.4.0"
4-
id("com.jfrog.artifactory") version "4.17.2"
54
`maven-publish`
5+
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
6+
signing
67
}
78

89
apply("versions.gradle.kts")
910

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

1314
repositories {
14-
jcenter()
1515
mavenCentral()
1616
}
1717

18+
nexusPublishing {
19+
repositories {
20+
sonatype()
21+
}
22+
}
23+
24+
apply(plugin = "io.github.gradle-nexus.publish-plugin")
25+
apply(plugin = "maven-publish")
26+
apply(plugin = "signing")
27+
1828
kotlin {
1929
explicitApi()
2030
jvm {
@@ -124,77 +134,9 @@ publishing {
124134
}
125135
}
126136

127-
publishing {
128-
val bintrayOrg = "microutils"
129-
val bintrayRepo = "kotlin-logging"
130-
val bintrayUser = System.getProperty("bintray.user")
131-
val bintrayApiKey = System.getProperty("bintray.key")
132-
133-
if (bintrayUser != null && bintrayApiKey != null) {
134-
repositories {
135-
maven {
136-
name = "bintray"
137-
url = uri(
138-
"https://api.bintray.com/maven/$bintrayOrg/$bintrayRepo/${project.name}/;publish=1;override=1"
139-
)
140-
credentials {
141-
username = bintrayUser
142-
password = bintrayApiKey
143-
}
144-
}
145-
}
146-
}
147-
}
148-
149-
//bintray {
150-
// user = System.getProperty("bintray.user")
151-
// key = System.getProperty("bintray.key") //https://bintray.com/profile/edit
152-
// setPublications(*publishing.publications.names.toTypedArray())
153-
// publish = true //[Default: false] Whether version should be auto published after an upload
154-
// pkg.apply {
155-
// repo = "kotlin-logging"
156-
// name = "kotlin-logging"
157-
// userOrg = "microutils"
158-
// setLicenses("Apache-2.0")
159-
// vcsUrl = "https://github.com/MicroUtils/kotlin-logging"
160-
// websiteUrl = "https://github.com/MicroUtils/kotlin-logging"
161-
// issueTrackerUrl = "https://github.com/MicroUtils/kotlin-logging/issues"
162-
//
163-
// githubRepo = "MicroUtils/kotlin-logging"
164-
// githubReleaseNotesFile = "ChangeLog.md"
165-
// version.apply {
166-
// name = "${project.version}"
167-
// desc = "kotlin-logging - Lightweight logging framework for Kotlin"
168-
// released = "${Date()}"
169-
// gpg.sign = true //Determines whether to GPG sign the files. The default is false
170-
// mavenCentralSync.apply {
171-
// sync = true //[Default: true] Determines whether to sync the version to Maven Central.
172-
// user = System.getProperty("maven.user") //OSS user token: mandatory
173-
// password = System.getProperty("maven.password") //OSS user password: mandatory
174-
// close =
175-
// "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.
176-
// }
177-
// }
178-
// }
179-
//}
180-
181-
artifactory {
182-
setContextUrl("http://oss.jfrog.org")
183-
publish(delegateClosureOf<org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig> {
184-
repository(delegateClosureOf<groovy.lang.GroovyObject> {
185-
setProperty("repoKey", "oss-snapshot-local")
186-
setProperty("username", System.getProperty("bintray.user"))
187-
setProperty("password", System.getProperty("bintray.key"))
188-
setProperty("maven", true)
189-
})
190-
defaults(delegateClosureOf<groovy.lang.GroovyObject> {
191-
invokeMethod("publications", publishing.publications.names.toTypedArray())
192-
setProperty("publishArtifacts", true)
193-
setProperty("publishPom", true)
194-
})
195-
})
196-
resolve(delegateClosureOf<org.jfrog.gradle.plugin.artifactory.dsl.ResolverConfig> {
197-
setProperty("repoKey", "jcenter")
198-
})
199-
clientConfig.info.buildNumber = System.getProperty("build.number")
137+
signing {
138+
val signingKey: String? by project
139+
val signingPassword: String? by project
140+
useInMemoryPgpKeys(signingKey, signingPassword)
141+
sign(publishing.publications)
200142
}

0 commit comments

Comments
 (0)