11plugins {
22 groovy
33 id(" maven-publish" )
4- id(" org.jetbrains.kotlin.jvm" ) version(" 1.4.20" )
4+ id(" signing" )
5+ id(" org.jetbrains.kotlin.jvm" ) version(" 1.4.30" )
56 id(" com.github.ben-manes.versions" ) version (" 0.36.0" )
67}
78
@@ -15,18 +16,57 @@ tasks.compileKotlin {
1516 kotlinOptions.jvmTarget = " 1.8"
1617}
1718
18- repositories {
19- mavenCentral()
20- maven {
21- setUrl(" https://dl.bintray.com/openapi-processor/primary" )
19+ fun getBuildProperty (property : String ): String {
20+ val prop: String? = project.findProperty(property) as String?
21+ if (prop != null ) {
22+ return prop
23+ }
24+
25+ val env: String? = System .getenv(property)
26+ if (env != null ) {
27+ return env
2228 }
29+
30+ return " n/a"
31+ }
32+
33+ fun getBuildSignKey (property : String ): String {
34+ val prop: String? = project.findProperty(property) as String?
35+ if (prop != null ) {
36+ return prop
37+ }
38+
39+ val env: String? = System .getenv(property)
40+ if (env != null ) {
41+ return env.replace(" \\ n" , " \n " )
42+ }
43+
44+ return " n/a"
45+ }
46+
47+ fun isReleaseVersion (): Boolean {
48+ return ! (project.version.toString().endsWith(" SNAPSHOT" ))
2349}
2450
2551project.ext {
26- set(" processorApiVersion" , " 2020.3 " )
52+ set(" processorApiVersion" , " 2021.1 " )
2753
28- set(" bintrayUser" , project.findProperty(" BINTRAY_USER" ) ? : System .getenv(" BINTRAY_USER" ) ? : " n/a" )
29- set(" bintrayKey" , project.findProperty(" BINTRAY_KEY" ) ? : System .getenv(" BINTRAY_KEY" ) ? : " n/a" )
54+ set(" publishUser" , getBuildProperty(" PUBLISH_USER" ))
55+ set(" publishKey" , getBuildProperty(" PUBLISH_KEY" ))
56+ set(" signKey" , getBuildSignKey(" SIGN_KEY" ))
57+ set(" signPwd" , getBuildProperty(" SIGN_PWD" ))
58+ }
59+
60+
61+ repositories {
62+ mavenCentral()
63+ maven {
64+ setUrl(" https://oss.sonatype.org/content/repositories/snapshots" )
65+ mavenContent {
66+ snapshotsOnly()
67+ }
68+ }
69+ jcenter()
3070}
3171
3272dependencies {
@@ -38,7 +78,7 @@ dependencies {
3878 }
3979 compileOnly(" io.openapiprocessor:openapi-processor-api:${project.ext.get(" processorApiVersion" )} " )
4080
41- testImplementation(" net.bytebuddy:byte-buddy:1.10.19 " )
81+ testImplementation(" net.bytebuddy:byte-buddy:1.10.20 " )
4282 testImplementation(" org.spockframework:spock-core:1.3-groovy-2.5" ) {
4383 exclude(group = " org.codehaus.groovy" , module = " groovy-json" )
4484 exclude(group = " org.codehaus.groovy" , module = " groovy-macro" )
@@ -80,8 +120,11 @@ val projectTitle: String by project
80120val projectDesc: String by project
81121val projectUrl: String by project
82122val projectGithubRepo: String by project
83- val bintrayUser: String by project.ext
84- val bintrayKey: String by project.ext
123+
124+ // does not work on oss.sonatype.org
125+ tasks.withType<GenerateModuleMetadata >().configureEach {
126+ enabled = false
127+ }
85128
86129publishing {
87130 publications {
@@ -96,7 +139,7 @@ publishing {
96139
97140 pom {
98141 name.set(projectTitle)
99- description.set(" $projectTitle - $ projectDesc - ${project.name} module " )
142+ description.set(projectDesc)
100143 url.set(projectUrl)
101144
102145 licenses {
@@ -123,18 +166,31 @@ publishing {
123166
124167 repositories {
125168 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 (hasSnapshotVersion ()) snapshotsRepoUrl else releasesRepoUrl )
169+ val releasesRepoUrl = " https://oss.sonatype.org/service/local/staging/deploy/maven2 "
170+ val snapshotsRepoUrl = " https://oss.sonatype .org/content/repositories/snapshots "
171+ url = uri(if (isReleaseVersion ()) releasesRepoUrl else snapshotsRepoUrl )
129172
130173 credentials {
131- username = project.ext.get( " bintrayUser " ) .toString()
132- password = project.ext.get( " bintrayKey " ) .toString()
174+ username = project.extra[ " publishUser " ] .toString()
175+ password = project.extra[ " publishKey " ] .toString()
133176 }
134177 }
135178 }
136179}
137180
181+ // tasks.withType<Sign>().configureEach {
182+ // onlyIf { isReleaseVersion() }
183+ // }
184+
185+ signing {
186+ useInMemoryPgpKeys(
187+ project.extra[" signKey" ].toString(),
188+ project.extra[" signPwd" ].toString())
189+
190+ sign(publishing.publications[" OpenApiProcessor" ])
191+ }
192+
193+
138194registerPublishTask(" snapshot" ) { hasSnapshotVersion() }
139195registerPublishTask(" release" ) { ! hasSnapshotVersion() }
140196
0 commit comments