Skip to content

Commit 44ff21b

Browse files
committed
sign/publish to oss.sonatype.org
1 parent 02afc2a commit 44ff21b

File tree

2 files changed

+49
-25
lines changed

2 files changed

+49
-25
lines changed

build.gradle.kts

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
groovy
33
id("java-library")
44
id("maven-publish")
5+
id("signing")
56
id("com.github.ben-manes.versions") version ("0.36.0")
67
}
78

@@ -16,28 +17,38 @@ java {
1617
targetCompatibility = JavaVersion.VERSION_1_8
1718
}
1819

20+
fun getBuildProperty(property: String): String {
21+
val prop: String? = project.findProperty(property) as String?
22+
if(prop != null) {
23+
return prop
24+
}
25+
26+
val env: String? = System.getenv(property)
27+
if (env != null) {
28+
return env
29+
}
30+
31+
return "n/a"
32+
}
33+
34+
fun isReleaseVersion(): Boolean {
35+
return !(project.version.toString().endsWith("SNAPSHOT"))
36+
}
37+
1938
ext {
20-
set("bintrayUser", project.findProperty("BINTRAY_USER") ?: "n/a")
21-
set("bintrayKey", project.findProperty("BINTRAY_KEY") ?: "n/a")
39+
set("publishUser", getBuildProperty("PUBLISH_USER"))
40+
set("publishKey", getBuildProperty("PUBLISH_KEY"))
41+
set("signKey", getBuildProperty("SIGN_KEY"))
42+
set("signPwd", getBuildProperty("SIGN_PWD"))
2243
}
2344

2445
repositories {
2546
mavenCentral()
2647

2748
maven {
28-
setUrl("https://dl.bintray.com/openapi-processor/primary")
29-
content {
30-
includeGroup ("io.openapiprocessor")
31-
}
32-
mavenContent {
33-
releasesOnly()
34-
}
35-
}
36-
37-
maven {
38-
setUrl("https://oss.jfrog.org/artifactory/oss-snapshot-local")
49+
setUrl("https://oss.sonatype.org/content/repositories/snapshots")
3950
content {
40-
includeGroup("io.openapiprocessor")
51+
includeGroup("io.openapiprocessor")
4152
}
4253
mavenContent {
4354
snapshotsOnly()
@@ -46,7 +57,7 @@ repositories {
4657
}
4758

4859
dependencies {
49-
compileOnly("io.openapiprocessor:openapi-processor-api:2020.3")
60+
compileOnly("io.openapiprocessor:openapi-processor-api:2021.1")
5061

5162
implementation("org.codehaus.groovy:groovy:3.0.7")
5263
implementation("org.codehaus.groovy:groovy-nio:3.0.7")
@@ -80,8 +91,11 @@ val projectTitle: String by project
8091
val projectDesc: String by project
8192
val projectUrl: String by project
8293
val projectGithubRepo: String by project
83-
val bintrayUser: String by project.ext
84-
val bintrayKey: String by project.ext
94+
95+
// does not work on oss.sonatype.org
96+
tasks.withType<GenerateModuleMetadata>().configureEach {
97+
enabled = false
98+
}
8599

86100
publishing {
87101
publications {
@@ -96,7 +110,7 @@ publishing {
96110

97111
pom {
98112
name.set(projectTitle)
99-
description.set("${projectTitle} - ${projectDesc} - ${project.name} module")
113+
description.set(projectDesc)
100114
url.set(projectUrl)
101115

102116
licenses {
@@ -123,14 +137,26 @@ publishing {
123137

124138
repositories {
125139
maven {
126-
val releasesRepoUrl = "https://api.bintray.com/maven/openapi-processor/primary/${project.name}/;publish=1;override=0"
127-
val snapshotsRepoUrl = "https://oss.jfrog.org/oss-snapshot-local/"
128-
url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
140+
val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
141+
val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
142+
url = uri(if (isReleaseVersion()) releasesRepoUrl else snapshotsRepoUrl)
129143

130144
credentials {
131-
username = project.ext.get("bintrayUser").toString()
132-
password = project.ext.get("bintrayKey").toString()
145+
username = project.extra["publishUser"].toString()
146+
password = project.extra["publishKey"].toString()
133147
}
134148
}
135149
}
136150
}
151+
152+
tasks.withType<Sign>().configureEach {
153+
onlyIf { isReleaseVersion() }
154+
}
155+
156+
signing {
157+
useInMemoryPgpKeys(
158+
project.extra["signKey"].toString(),
159+
project.extra["signPwd"].toString())
160+
161+
sign(publishing.publications["OpenApiProcessor"])
162+
}

gradle.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,3 @@ projectTitle=openapi-processor
66
projectDesc=OpenAPI Processor Test
77

88
projectGithubRepo=openapi-processor/openapi-processor-test
9-
10-
systemProp.org.gradle.internal.publish.checksums.insecure=true

0 commit comments

Comments
 (0)