|
2 | 2 | * Copyright (c) 2023-2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
|
3 | 3 | */
|
4 | 4 |
|
5 |
| -plugins { |
6 |
| - `maven-publish` |
7 |
| - signing |
8 |
| -} |
9 |
| - |
10 |
| -val sonatypeUsername: String? by project |
11 |
| -val sonatypePassword: String? by project |
| 5 | +import com.vanniktech.maven.publish.* |
12 | 6 |
|
13 |
| -val signingKey: String? by project |
14 |
| -val signingPassword: String? by project |
15 |
| - |
16 |
| -signing { |
17 |
| - isRequired = sonatypeUsername != null && sonatypePassword != null |
18 |
| - useInMemoryPgpKeys(signingKey, signingPassword) |
19 |
| - sign(publishing.publications) |
| 7 | +plugins { |
| 8 | + id("com.vanniktech.maven.publish.base") |
20 | 9 | }
|
21 | 10 |
|
22 |
| -val javadocJar by tasks.registering(Jar::class) { archiveClassifier.set("javadoc") } |
23 |
| - |
24 |
| -// this is somewhat a hack because we have single javadoc artifact which is used for all publications |
25 |
| -tasks.withType<Sign>().configureEach { dependsOn(javadocJar) } |
26 |
| -tasks.withType<AbstractPublishToMaven>().configureEach { dependsOn(tasks.withType<Sign>()) } |
27 |
| - |
28 |
| -publishing { |
29 |
| - repositories { |
30 |
| - maven { |
31 |
| - name = "snapshot" |
32 |
| - url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") |
33 |
| - credentials { |
34 |
| - username = sonatypeUsername |
35 |
| - password = sonatypePassword |
| 11 | +mavenPublishing { |
| 12 | + publishToMavenCentral(SonatypeHost.S01) |
| 13 | + signAllPublications() |
| 14 | + |
| 15 | + pom { |
| 16 | + name.set(project.name) |
| 17 | + description.set(provider { |
| 18 | + checkNotNull(project.description) { "Project description isn't set for project: ${project.path}" } |
| 19 | + }) |
| 20 | + url.set("https://github.com/whyoleg/cryptography-kotlin") |
| 21 | + |
| 22 | + licenses { |
| 23 | + license { |
| 24 | + name.set("The Apache Software License, Version 2.0") |
| 25 | + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") |
| 26 | + distribution.set("repo") |
36 | 27 | }
|
37 | 28 | }
|
38 |
| - maven { |
39 |
| - name = "mavenCentral" |
40 |
| - url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") |
41 |
| - credentials { |
42 |
| - username = sonatypeUsername |
43 |
| - password = sonatypePassword |
| 29 | + developers { |
| 30 | + developer { |
| 31 | + id.set("whyoleg") |
| 32 | + name.set("Oleg Yukhnevich") |
| 33 | + |
44 | 34 | }
|
45 | 35 | }
|
46 |
| - maven { |
47 |
| - name = "projectLocal" |
48 |
| - url = uri(rootProject.layout.buildDirectory.dir("mavenProjectLocal")) |
49 |
| - } |
50 |
| - } |
51 |
| - |
52 |
| - publications.withType<MavenPublication>().configureEach { |
53 |
| - artifact(javadocJar) |
54 |
| - pom { |
55 |
| - name.set(project.name) |
56 |
| - description.set(provider { |
57 |
| - checkNotNull(project.description) { "Project description isn't set for project: ${project.path}" } |
58 |
| - }) |
| 36 | + scm { |
| 37 | + connection.set("https://github.com/whyoleg/cryptography-kotlin.git") |
| 38 | + developerConnection.set("https://github.com/whyoleg/cryptography-kotlin.git") |
59 | 39 | url.set("https://github.com/whyoleg/cryptography-kotlin")
|
60 |
| - |
61 |
| - licenses { |
62 |
| - license { |
63 |
| - name.set("The Apache Software License, Version 2.0") |
64 |
| - url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") |
65 |
| - distribution.set("repo") |
66 |
| - } |
67 |
| - } |
68 |
| - developers { |
69 |
| - developer { |
70 |
| - id.set("whyoleg") |
71 |
| - name.set("Oleg Yukhnevich") |
72 |
| - |
73 |
| - } |
74 |
| - } |
75 |
| - scm { |
76 |
| - connection.set("https://github.com/whyoleg/cryptography-kotlin.git") |
77 |
| - developerConnection.set("https://github.com/whyoleg/cryptography-kotlin.git") |
78 |
| - url.set("https://github.com/whyoleg/cryptography-kotlin") |
79 |
| - } |
80 | 40 | }
|
81 | 41 | }
|
82 | 42 | }
|
| 43 | + |
| 44 | +// javadocJar setup |
| 45 | +// we have a single javadoc artifact which is used for all publications, |
| 46 | +// and so we need to manually create task dependencies to make Gradle happy |
| 47 | +val javadocJar by tasks.registering(Jar::class) { archiveClassifier.set("javadoc") } |
| 48 | +tasks.withType<Sign>().configureEach { dependsOn(javadocJar) } |
| 49 | +tasks.withType<AbstractPublishToMaven>().configureEach { dependsOn(tasks.withType<Sign>()) } |
| 50 | +publishing.publications.withType<MavenPublication>().configureEach { artifact(javadocJar) } |
0 commit comments