|
| 1 | +import io.openapiprocessor.build.core.dsl.initFrom |
| 2 | +import io.openapiprocessor.build.core.dsl.initSignKey |
| 3 | +import io.openapiprocessor.build.core.dsl.sonatype |
| 4 | +import io.openapiprocessor.build.core.getPomProperties |
1 | 5 | import org.gradle.accessors.dm.LibrariesForLibs |
2 | 6 |
|
3 | 7 | plugins { |
4 | | - id("maven-publish") |
5 | | - id("signing") |
| 8 | + id("io.openapiprocessor.build.plugin.publish-central") |
6 | 9 | } |
7 | 10 |
|
8 | | -// see buildSrc/build.gradle catalog hack |
| 11 | +// see buildSrc/build.gradle.kts |
9 | 12 | val libs = the<LibrariesForLibs>() |
10 | 13 |
|
11 | | -fun properties(key: String): Provider<String> = providers.gradleProperty(key) |
12 | | -val componentName = if (isPlatform()) { "javaPlatform" } else { "java" } |
13 | | - |
14 | 14 | publishing { |
15 | 15 | publications { |
16 | 16 | create<MavenPublication>("openapiprocessor") { |
17 | | - from(components[componentName]) |
| 17 | + from(components["java"]) |
18 | 18 |
|
19 | 19 | pom { |
20 | | - group = "io.openapiprocessor" |
21 | | - version = libs.versions.processor.get() |
22 | | - |
23 | | - name.set("openapi-processor") |
24 | | - description.set("OpenAPI Processor") |
25 | | - url.set("https://openapiprocessor.io") |
26 | | - |
27 | | - licenses { |
28 | | - license { |
29 | | - name.set("The Apache License, Version 2.0") |
30 | | - url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") |
31 | | - distribution.set("repo") |
32 | | - } |
33 | | - } |
34 | | - |
35 | | - developers { |
36 | | - developer { |
37 | | - id.set("hauner") |
38 | | - name.set("Martin Hauner") |
39 | | - } |
40 | | - } |
41 | | - |
42 | | - scm { |
43 | | - url.set("https://github.com/openapi-processor/openapi-processor-base") |
44 | | - } |
| 20 | + pom.initFrom(getPomProperties(project)) |
45 | 21 | } |
46 | 22 | } |
47 | 23 | } |
48 | 24 |
|
49 | 25 | repositories { |
50 | | - maven { |
51 | | - val releasesRepoUrl = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2" |
52 | | - val snapshotsRepoUrl = "https://central.sonatype.com/repository/maven-snapshots" |
53 | | - url = uri(if (isReleaseVersion()) releasesRepoUrl else snapshotsRepoUrl) |
54 | | - |
55 | | - credentials { |
56 | | - username = buildProperty("PUBLISH_USER") |
57 | | - password = buildProperty("PUBLISH_KEY") |
58 | | - } |
59 | | - } |
| 26 | + sonatype(project) |
60 | 27 | } |
61 | 28 | } |
62 | 29 |
|
63 | | -// signing requires the sign key and pwd as environment variables: |
64 | | -// |
65 | | -// ORG_GRADLE_PROJECT_signKey=... |
66 | | -// ORG_GRADLE_PROJECT_signPwd=... |
67 | | - |
68 | 30 | signing { |
69 | | - setRequired({ gradle.taskGraph.hasTask("${project.path}:publishToSonatype") }) |
70 | | - |
71 | | - val signKey: String? by project |
72 | | - val signPwd: String? by project |
73 | | - useInMemoryPgpKeys(signKey, signPwd) |
74 | | - |
| 31 | + initSignKey() |
75 | 32 | sign(publishing.publications["openapiprocessor"]) |
76 | 33 | } |
0 commit comments