1
1
package buildsrc.convention
2
2
3
+ import buildsrc.config.createKxsTsGenPom
4
+ import buildsrc.config.credentialsAction
5
+ import buildsrc.config.isKotlinMultiplatformJavaEnabled
3
6
import buildsrc.config.publishing
4
7
import buildsrc.config.signing
5
- import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
6
8
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
7
- import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
8
9
9
10
10
11
plugins {
@@ -13,15 +14,8 @@ plugins {
13
14
}
14
15
15
16
val sonatypeRepositoryCredentials: Provider <Action <PasswordCredentials >> =
16
- providers.zip(
17
- providers.gradleProperty(" sonatypeRepositoryUsername" ),
18
- providers.gradleProperty(" sonatypeRepositoryPassword" ),
19
- ) { user, pass ->
20
- Action <PasswordCredentials > {
21
- username = user
22
- password = pass
23
- }
24
- }
17
+ providers.credentialsAction(" sonatypeRepository" )
18
+
25
19
26
20
val sonatypeRepositoryReleaseUrl: Provider <String > = provider {
27
21
if (version.toString().endsWith(" SNAPSHOT" )) {
@@ -49,36 +43,36 @@ val javadocJarStub by tasks.registering(Jar::class) {
49
43
}
50
44
51
45
52
- tasks.matching {
53
- it.name.startsWith(PublishingPlugin .PUBLISH_LIFECYCLE_TASK_NAME )
54
- && it.group == PublishingPlugin .PUBLISH_TASK_GROUP
55
- }.configureEach {
46
+ tasks.withType<AbstractPublishToMaven >().configureEach {
47
+ // Gradle warns about some signing tasks using publishing task outputs without explicit
48
+ // dependencies. I'm not going to go through them all and fix them, so here's a quick fix.
49
+ dependsOn(tasks.withType<Sign >())
50
+
56
51
if (sonatypeRepositoryCredentials.isPresent()) {
57
52
dependsOn(javadocJarStub)
58
53
}
54
+
59
55
doLast {
60
56
logger.lifecycle(" [${this .name} ] ${project.group} :${project.name} :${project.version} " )
61
57
}
62
58
}
63
59
64
60
65
- // Gradle warns about some signing tasks using publishing task outputs without explicit
66
- // dependencies. I'm not going to go through them all and fix them, so here's a quick safety check.
67
- tasks.matching { it.name.startsWith(" publish" ) }.configureEach {
68
- mustRunAfter(tasks.matching { it.name.startsWith(" sign" ) })
69
- }
70
-
71
-
72
61
publishing {
73
62
if (sonatypeRepositoryCredentials.isPresent()) {
74
63
repositories {
75
64
maven(sonatypeRepositoryReleaseUrl) {
76
65
name = " sonatype"
77
66
credentials(sonatypeRepositoryCredentials.get())
78
67
}
68
+ // publish to local dir, for testing
69
+ // maven {
70
+ // name = "maven-internal"
71
+ // url = uri(rootProject.layout.buildDirectory.dir("maven-internal"))
72
+ // }
79
73
}
80
74
publications.withType<MavenPublication >().configureEach {
81
- createKxTsGenPom ()
75
+ createKxsTsGenPom ()
82
76
artifact(javadocJarStub)
83
77
}
84
78
}
@@ -124,40 +118,3 @@ plugins.withType(JavaPlatformPlugin::class).configureEach {
124
118
from(components[" javaPlatform" ])
125
119
}
126
120
}
127
-
128
-
129
- fun MavenPublication.createKxTsGenPom (): Unit = pom {
130
- name.set(" Kotlinx Serialization Typescript Generator" )
131
- description.set(" KxTsGen creates TypeScript interfaces from Kotlinx Serialization @Serializable classes" )
132
- url.set(" https://github.com/adamko-dev/kotlinx-serialization-typescript-generator" )
133
-
134
- licenses {
135
- license {
136
- name.set(" The Apache License, Version 2.0" )
137
- url.set(" https://www.apache.org/licenses/LICENSE-2.0.txt" )
138
- }
139
- }
140
-
141
- developers {
142
- developer {
143
-
144
- }
145
- }
146
-
147
- scm {
148
- connection.set(" scm:git:git://github.com/adamko-dev/kotlinx-serialization-typescript-generator.git" )
149
- developerConnection.set(" scm:git:ssh://github.com:adamko-dev/kotlinx-serialization-typescript-generator.git" )
150
- url.set(" https://github.com/adamko-dev/kotlinx-serialization-typescript-generator" )
151
- }
152
- }
153
-
154
-
155
- /* * Logic from [KotlinJvmTarget.withJava] */
156
- fun Project.isKotlinMultiplatformJavaEnabled (): Boolean {
157
- val multiplatformExtension: KotlinMultiplatformExtension ? =
158
- extensions.findByType(KotlinMultiplatformExtension ::class )
159
-
160
- return multiplatformExtension?.targets
161
- ?.any { it is KotlinJvmTarget && it.withJavaEnabled }
162
- ? : false
163
- }
0 commit comments