@@ -2,41 +2,38 @@ package buildsrc.convention
2
2
3
3
import buildsrc.config.publishing
4
4
import buildsrc.config.signing
5
- import org.gradle.api.credentials.PasswordCredentials
6
- import org.gradle.internal.credentials.DefaultPasswordCredentials
7
5
8
6
plugins {
9
- id(" buildsrc.convention.subproject" )
10
7
`maven- publish`
11
8
signing
12
9
}
13
10
14
-
15
- // val sonatypeRepositoryCredentials: Provider<PasswordCredentials> =
16
- // providers.credentials(PasswordCredentials::class, "sonatypeRepositoryCredentials")
17
-
18
- val sonatypeRepositoryUsername: String? by project.extra
19
- val sonatypeRepositoryPassword: String? by project.extra
20
- val sonatypeRepositoryCredentials: Provider <PasswordCredentials > = providers.provider {
21
- if (sonatypeRepositoryUsername.isNullOrBlank() || sonatypeRepositoryPassword.isNullOrBlank()) {
22
- null
23
- } else {
24
- DefaultPasswordCredentials (sonatypeRepositoryUsername, sonatypeRepositoryPassword)
11
+ val sonatypeRepositoryCredentials: Provider <Action <PasswordCredentials >> = providers
12
+ .credentials(PasswordCredentials ::class , " sonatypeRepository" )
13
+ .map { credentials ->
14
+ Action <PasswordCredentials > {
15
+ username = credentials.username
16
+ password = credentials.password
17
+ }
25
18
}
26
- }
27
-
28
-
29
- val sonatypeRepositoryId: String by project.extra
30
19
31
20
val sonatypeRepositoryReleaseUrl: Provider <String > = provider {
32
21
if (version.toString().endsWith(" SNAPSHOT" )) {
33
- " https://oss.sonatype.org/content/repositories/snapshots/"
22
+ " https://s01. oss.sonatype.org/content/repositories/snapshots/"
34
23
} else {
35
- " https://oss.sonatype.org/service/local/staging/deployByRepositoryId/ $sonatypeRepositoryId /"
24
+ " https://s01. oss.sonatype.org/service/local/staging/deploy/maven2 /"
36
25
}
37
26
}
38
27
39
28
29
+ val signingKeyId: Provider <String > =
30
+ providers.gradleProperty(" signing.keyId" )
31
+ val signingPassword: Provider <String > =
32
+ providers.gradleProperty(" signing.password" )
33
+ val signingSecretKeyRingFile: Provider <String > =
34
+ providers.gradleProperty(" signing.secretKeyRingFile" )
35
+
36
+
40
37
tasks.matching {
41
38
it.name.startsWith(PublishingPlugin .PUBLISH_LIFECYCLE_TASK_NAME )
42
39
&& it.group == PublishingPlugin .PUBLISH_TASK_GROUP
@@ -47,42 +44,97 @@ tasks.matching {
47
44
}
48
45
49
46
50
-
51
47
publishing {
52
48
repositories {
53
- if (sonatypeRepositoryCredentials.isPresent) {
54
- maven(sonatypeRepositoryReleaseUrl) {
55
- name = " oss"
56
- credentials {
57
- username = sonatypeRepositoryCredentials.get().username
58
- password = sonatypeRepositoryCredentials.get().password
59
- }
60
- }
49
+ maven(sonatypeRepositoryReleaseUrl) {
50
+ name = " sonatype"
51
+ credentials(sonatypeRepositoryCredentials.get())
61
52
}
62
53
}
54
+ publications.withType<MavenPublication >().configureEach {
55
+ createKxTsGenPom()
56
+ }
63
57
}
64
58
59
+
65
60
signing {
66
- val signingKeyId: String? by project
67
- val signingKey: String? by project
68
- val signingPassword: String? by project
69
- useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
70
- setRequired(false )
61
+
62
+ // if (
63
+ // signingKeyId.isPresent() &&
64
+ // signingPassword.isPresent() &&
65
+ // signingSecretKeyRingFile.isPresent()
66
+ // ) {
67
+ // useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
68
+ // } else {
69
+ // useGpgCmd()
70
+ // }
71
+
72
+ useGpgCmd()
73
+
74
+ // sign all publications
75
+ sign(publishing.publications)
71
76
}
72
77
73
78
74
- plugins.withType<JavaPlugin > {
75
- if (! plugins.hasPlugin(KotlinMultiplatformPlugin ::class )) {
76
- val publication = publishing.publications.create<MavenPublication >(" mavenJava" ) {
77
- from(components[" java" ])
79
+ plugins.configureEach {
80
+ when (this ) {
81
+ // not necessary? It looks like the plugin creates publications correctly?
82
+ // is KotlinMultiplatformPlugin -> {
83
+ //
84
+ // // Stub javadoc.jar artifact (required by Maven Central?)
85
+ // val javadocJar by tasks.registering(Jar::class) {
86
+ // archiveClassifier.set("javadoc")
87
+ // }
88
+ //
89
+ // publishing.publications.create<MavenPublication>("mavenKotlinMpp") {
90
+ // from(components["kotlin"])
91
+ // artifact(javadocJar)
92
+ // artifact(tasks["sourcesJar"])
93
+ // }
94
+ // }
95
+
96
+ // JavaPlugin clashes with KotlinMultiplatformPlugin?
97
+ // causes error
98
+ // Artifact kxs-ts-gen-core-jvm-maven-publish-SNAPSHOT.jar wasn't produced by this build
99
+ // is JavaPlugin -> afterEvaluate {
100
+ // if (!plugins.hasPlugin(KotlinMultiplatformPlugin::class)) {
101
+ // publishing.publications.create<MavenPublication>("mavenJava") {
102
+ // from(components["java"])
103
+ // artifact(tasks["sourcesJar"])
104
+ // }
105
+ // }
106
+ // }
107
+
108
+ is JavaPlatformPlugin -> {
109
+ publishing.publications.create<MavenPublication >(" mavenJavaPlatform" ) {
110
+ from(components[" javaPlatform" ])
111
+ }
78
112
}
79
- signing { sign(publication) }
80
113
}
81
114
}
82
115
83
- plugins.withType<JavaPlatformPlugin > {
84
- val publication = publishing.publications.create<MavenPublication >(" mavenJavaPlatform" ) {
85
- from(components[" javaPlatform" ])
116
+
117
+ fun MavenPublication.createKxTsGenPom (): Unit = pom {
118
+ name.set(" Kotlinx Serialization Typescript Generator" )
119
+ description.set(" KxTsGen creates TypeScript interfaces from Kotlinx Serialization @Serializable classes" )
120
+ url.set(" https://github.com/adamko-dev/kotlinx-serialization-typescript-generator" )
121
+
122
+ licenses {
123
+ license {
124
+ name.set(" The Apache License, Version 2.0" )
125
+ url.set(" http://www.apache.org/licenses/LICENSE-2.0.txt" )
126
+ }
127
+ }
128
+
129
+ developers {
130
+ developer {
131
+
132
+ }
133
+ }
134
+
135
+ scm {
136
+ connection.set(" scm:git:git://github.com/adamko-dev/kotlinx-serialization-typescript-generator.git" )
137
+ developerConnection.set(" scm:git:ssh://github.com:adamko-dev/kotlinx-serialization-typescript-generator.git" )
138
+ url.set(" https://github.com/adamko-dev/kotlinx-serialization-typescript-generator" )
86
139
}
87
- signing { sign(publication) }
88
140
}
0 commit comments