Skip to content

Commit 6c43438

Browse files
committed
sign & publish to oss.sonatype.org
1 parent 92a8196 commit 6c43438

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
2-
id 'java'
32
id 'java-library'
43
id 'maven-publish'
4+
id 'signing'
55
id "com.github.ben-manes.versions" version "0.36.0"
66
}
77

@@ -18,8 +18,10 @@ javadoc {
1818
}
1919

2020
ext {
21-
bintrayUser = project.hasProperty ('BINTRAY_USER') ? BINTRAY_USER : 'n/a'
22-
bintrayKey = project.hasProperty ('BINTRAY_KEY') ? BINTRAY_KEY : 'n/a'
21+
publishUser = project.findProperty ('PUBLISH_USER') ?: System.getenv ("PUBLISH_USER") ?: 'n/a'
22+
publishKey = project.findProperty ('PUBLISH_KEY') ?: System.getenv ("PUBLISH_KEY") ?: 'n/a'
23+
24+
isReleaseVersion = !version.endsWith("SNAPSHOT")
2325
}
2426

2527
repositories {

gradle/publishing.gradle

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// does not work on oss.sonatype.org
2+
tasks.withType(GenerateModuleMetadata) {
3+
enabled = false
4+
}
5+
16
publishing {
27
publications {
38
OpenApiProcessor (MavenPublication) {
@@ -11,8 +16,7 @@ publishing {
1116

1217
pom {
1318
name = project.projectTitle
14-
// description = project.projectDesc
15-
description = "${project.projectTitle} - ${project.projectDesc} - ${project.name} module".toString()
19+
description = project.projectDesc
1620
url = project.projectUrl
1721

1822
licenses {
@@ -40,14 +44,30 @@ publishing {
4044

4145
repositories {
4246
maven {
43-
def releaseRepository = uri("https://api.bintray.com/maven/openapi-processor/primary/${project.name}/;publish=1;override=0")
44-
def snapshotRepository = uri("https://oss.jfrog.org/oss-snapshot-local/")
45-
url = version.endsWith('SNAPSHOT') ? snapshotRepository : releaseRepository
47+
def releaseRepository = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2")
48+
def snapshotRepository = uri("https://oss.sonatype.org/content/repositories/snapshots")
49+
url = project.isReleaseVersion ? releaseRepository : snapshotRepository
4650

4751
credentials {
48-
username = bintrayUser
49-
password = bintrayKey
52+
username = publishUser
53+
password = publishKey
5054
}
5155
}
56+
57+
}
58+
}
59+
60+
tasks.withType(Sign) {
61+
onlyIf { project.isReleaseVersion }
62+
}
63+
64+
signing {
65+
String signingKey = project.findProperty ('SIGN_KEY') ?: System.getenv ("SIGN_KEY") ?: 'n/a'
66+
String signingPwd = project.findProperty ('SIGN_PWD') ?: System.getenv ("SIGN_PWD") ?: 'n/a'
67+
68+
useInMemoryPgpKeys(signingKey, signingPwd)
69+
70+
signing {
71+
sign publishing.publications.OpenApiProcessor
5272
}
5373
}

0 commit comments

Comments
 (0)