1
1
package buildsrc.convention
2
2
3
- import buildsrc.config.*
3
+ import buildsrc.config.createKxsTsGenPom
4
+ import buildsrc.config.credentialsAction
5
+ import buildsrc.config.isKotlinMultiplatformJavaEnabled
4
6
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
5
7
6
8
@@ -32,19 +34,6 @@ val signingSecretKeyRingFile: Provider<String> =
32
34
providers.gradleProperty(" signing.secretKeyRingFile" )
33
35
34
36
35
-
36
- tasks.withType<AbstractPublishToMaven >().configureEach {
37
- // Gradle warns about some signing tasks using publishing task outputs without explicit
38
- // dependencies. I'm not going to go through them all and fix them, so here's a quick fix.
39
- dependsOn(tasks.withType<Sign >())
40
- mustRunAfter(tasks.withType<Sign >())
41
-
42
- doLast {
43
- logger.lifecycle(" [${path} ] ${publication?.groupId} :${publication?.artifactId} :${publication?.version} " )
44
- }
45
- }
46
-
47
-
48
37
signing {
49
38
if (sonatypeRepositoryCredentials.isPresent()) {
50
39
if (signingKeyId.isPresent() && signingKey.isPresent() && signingPassword.isPresent()) {
@@ -70,7 +59,25 @@ afterEvaluate {
70
59
}
71
60
}
72
61
73
- val javadocJarStub = javadocStubTask()
62
+ // region Javadoc JAR stub
63
+ // use creating, not registering, because the signing plugin doesn't accept task providers
64
+ val javadocJarStub by tasks.creating(Jar ::class ) {
65
+ group = JavaBasePlugin .DOCUMENTATION_GROUP
66
+ description = " Stub javadoc.jar artifact (required by Maven Central)"
67
+ archiveClassifier.set(" javadoc" )
68
+ }
69
+
70
+ tasks.withType<AbstractPublishToMaven >().all {
71
+ dependsOn(javadocJarStub)
72
+ }
73
+
74
+ if (sonatypeRepositoryCredentials.isPresent()) {
75
+ val signingTasks = signing.sign(javadocJarStub)
76
+ tasks.withType<AbstractPublishToMaven >().all {
77
+ signingTasks.forEach { dependsOn(it) }
78
+ }
79
+ }
80
+ // endregion
74
81
75
82
publishing {
76
83
if (sonatypeRepositoryCredentials.isPresent()) {
@@ -119,26 +126,36 @@ plugins.withType<JavaPlatformPlugin>().configureEach {
119
126
}
120
127
}
121
128
129
+ // region Fix Gradle warning about signing tasks using publishing task outputs without explicit dependencies
130
+ // https://youtrack.jetbrains.com/issue/KT-46466 https://github.com/gradle/gradle/issues/26091
131
+ tasks.withType<AbstractPublishToMaven >().configureEach {
132
+ val signingTasks = tasks.withType<Sign >()
133
+ mustRunAfter(signingTasks)
134
+ }
135
+ // endregion
122
136
123
- fun Project. javadocStubTask (): Jar {
124
-
125
- // use creating, not registering, because the signing plugin sucks
126
- val javadocJarStub by tasks.creating( Jar :: class ) {
127
- group = JavaBasePlugin . DOCUMENTATION_GROUP
128
- description = " Stub javadoc.jar artifact (required by Maven Central) "
129
- archiveClassifier.set( " javadoc " )
137
+ // region publishing logging
138
+ tasks.withType< AbstractPublishToMaven >().configureEach {
139
+ val publicationGAV = provider { publication?. run { " $group : $artifactId : $version " } }
140
+ doLast( " log publication GAV " ) {
141
+ if (publicationGAV.isPresent) {
142
+ logger.lifecycle( " [task: ${path} ] ${publicationGAV.get()} " )
143
+ }
130
144
}
145
+ }
146
+ // endregion
131
147
132
- tasks.withType<AbstractPublishToMaven >().all {
133
- dependsOn(javadocJarStub)
134
- }
148
+ // region IJ workarounds
149
+ // manually define the Kotlin DSL accessors because IntelliJ _still_ doesn't load them properly
150
+ fun Project.publishing (configure : PublishingExtension .() -> Unit ): Unit =
151
+ extensions.configure(configure)
135
152
136
- if (sonatypeRepositoryCredentials.isPresent()) {
137
- val signingTasks = signing.sign(javadocJarStub)
138
- tasks.withType<AbstractPublishToMaven >().all {
139
- signingTasks.forEach { dependsOn(it) }
140
- }
141
- }
153
+ val Project .publishing: PublishingExtension
154
+ get() = extensions.getByType()
142
155
143
- return javadocJarStub
144
- }
156
+ fun Project.signing (configure : SigningExtension .() -> Unit ): Unit =
157
+ extensions.configure(configure)
158
+
159
+ val Project .signing: SigningExtension
160
+ get() = extensions.getByType()
161
+ // endregion
0 commit comments