|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
17 | | -plugins { |
18 | | - `maven-publish` |
19 | | - signing |
20 | | -} |
21 | | - |
22 | | -val githubUsername: String? by project |
23 | | -val githubPassword: String? by project |
24 | | - |
25 | | -val sonatypeUsername: String? by project |
26 | | -val sonatypePassword: String? by project |
27 | | - |
28 | | -val signingKey: String? by project |
29 | | -val signingPassword: String? by project |
| 17 | +import com.vanniktech.maven.publish.* |
30 | 18 |
|
31 | | -// TODO: refactor publication a bit, so that version in gradle.properties will not contain SNAPSHOT |
32 | | -val versionSuffix = providers.gradleProperty("rsocketbuild.versionSuffix").orNull |
33 | | -if (versionSuffix != null) { |
34 | | - val versionString = project.version.toString() |
35 | | - require(versionString.endsWith("-SNAPSHOT")) |
36 | | - project.version = versionString.replace("-", "-${versionSuffix}-") |
37 | | - println("Current version: ${project.version}") |
| 19 | +plugins { |
| 20 | + id("com.vanniktech.maven.publish.base") |
38 | 21 | } |
39 | 22 |
|
40 | | -// empty javadoc for maven central |
41 | | -val javadocJar by tasks.registering(Jar::class) { archiveClassifier.set("javadoc") } |
42 | | - |
43 | | -// this is somewhat a hack because we have a single javadoc artifact which is used for all publications |
44 | | -tasks.withType<Sign>().configureEach { dependsOn(javadocJar) } |
45 | | -tasks.withType<AbstractPublishToMaven>().configureEach { dependsOn(tasks.withType<Sign>()) } |
| 23 | +mavenPublishing { |
| 24 | + publishToMavenCentral(SonatypeHost.S01) |
| 25 | + signAllPublications() |
46 | 26 |
|
47 | | -publishing { |
48 | | - publications.withType<MavenPublication> { |
49 | | - artifact(javadocJar) |
50 | | - pom { |
51 | | - name.set(project.name) |
52 | | - description.set(provider { |
53 | | - checkNotNull(project.description) { "Project description isn't set for project: ${project.path}" } |
54 | | - }) |
55 | | - url.set("http://rsocket.io") |
| 27 | + pom { |
| 28 | + name.set(project.name) |
| 29 | + description.set(provider { |
| 30 | + checkNotNull(project.description) { "Project description isn't set for project: ${project.path}" } |
| 31 | + }) |
| 32 | + url.set("https://rsocket.io") |
56 | 33 |
|
57 | | - licenses { |
58 | | - license { |
59 | | - name.set("The Apache Software License, Version 2.0") |
60 | | - url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") |
61 | | - distribution.set("repo") |
62 | | - } |
63 | | - } |
64 | | - developers { |
65 | | - developer { |
66 | | - id.set("whyoleg") |
67 | | - name.set("Oleg Yukhnevich") |
68 | | - |
69 | | - } |
70 | | - developer { |
71 | | - id.set("OlegDokuka") |
72 | | - name.set("Oleh Dokuka") |
73 | | - |
74 | | - } |
75 | | - } |
76 | | - scm { |
77 | | - connection.set("https://github.com/rsocket/rsocket-kotlin.git") |
78 | | - developerConnection.set("https://github.com/rsocket/rsocket-kotlin.git") |
79 | | - url.set("https://github.com/rsocket/rsocket-kotlin") |
| 34 | + licenses { |
| 35 | + license { |
| 36 | + name.set("The Apache Software License, Version 2.0") |
| 37 | + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") |
| 38 | + distribution.set("repo") |
80 | 39 | } |
81 | 40 | } |
82 | | - } |
83 | | - |
84 | | - repositories { |
85 | | - // TODO: drop github and use sonatype (?) |
86 | | - maven { |
87 | | - name = "github" |
88 | | - url = uri("https://maven.pkg.github.com/rsocket/rsocket-kotlin") |
89 | | - credentials { |
90 | | - username = githubUsername |
91 | | - password = githubPassword |
| 41 | + developers { |
| 42 | + developer { |
| 43 | + id.set("whyoleg") |
| 44 | + name.set("Oleg Yukhnevich") |
| 45 | + |
92 | 46 | } |
93 | | - } |
94 | | - maven { |
95 | | - name = "sonatype" |
96 | | - url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2") |
97 | | - credentials { |
98 | | - username = sonatypeUsername |
99 | | - password = sonatypePassword |
| 47 | + developer { |
| 48 | + id.set("OlegDokuka") |
| 49 | + name.set("Oleh Dokuka") |
| 50 | + |
100 | 51 | } |
101 | 52 | } |
| 53 | + scm { |
| 54 | + connection.set("https://github.com/rsocket/rsocket-kotlin.git") |
| 55 | + developerConnection.set("https://github.com/rsocket/rsocket-kotlin.git") |
| 56 | + url.set("https://github.com/rsocket/rsocket-kotlin") |
| 57 | + } |
102 | 58 | } |
103 | 59 | } |
104 | 60 |
|
105 | | -signing { |
106 | | - isRequired = sonatypeUsername != null && sonatypePassword != null |
107 | | - useInMemoryPgpKeys(signingKey, signingPassword) |
108 | | - sign(publishing.publications) |
109 | | -} |
| 61 | +// javadocJar setup |
| 62 | +// we have a single javadoc artifact which is used for all publications, |
| 63 | +// and so we need to manually create task dependencies to make Gradle happy |
| 64 | +val javadocJar by tasks.registering(Jar::class) { archiveClassifier.set("javadoc") } |
| 65 | +tasks.withType<Sign>().configureEach { dependsOn(javadocJar) } |
| 66 | +tasks.withType<AbstractPublishToMaven>().configureEach { dependsOn(tasks.withType<Sign>()) } |
| 67 | +publishing.publications.withType<MavenPublication>().configureEach { artifact(javadocJar) } |
0 commit comments