18
18
* If not, see <https://www.gnu.org/licenses/>.
19
19
*/
20
20
21
- import love.forte.gradle.common.core.Gpg
21
+ import com.vanniktech.maven.publish.SonatypeHost
22
22
import love.forte.gradle.common.core.project.setup
23
+ import love.forte.gradle.common.core.property.ofIf
23
24
import love.forte.gradle.common.core.property.systemProp
24
- import love.forte.gradle.common.publication.configure.configPublishMaven
25
- import love.forte.gradle.common.publication.configure.publishingExtension
26
- import love.forte.gradle.common.publication.configure.setupPom
25
+ import org.gradle.internal.impldep.org.bouncycastle.asn1.x509.X509ObjectIdentifiers.organization
27
26
28
27
plugins {
29
28
kotlin(" multiplatform" )
30
29
signing
31
- `maven- publish`
30
+ // https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-publish-libraries.html#configure-the-project
31
+ id(" com.vanniktech.maven.publish" )
32
32
id(" org.jetbrains.dokka" )
33
33
}
34
34
@@ -38,48 +38,96 @@ setup(P)
38
38
val p = project
39
39
val isSnapshot = project.version.toString().contains(" SNAPSHOT" , true )
40
40
41
- val jarJavadoc by tasks.registering(Jar ::class ) {
42
- group = " documentation"
43
- archiveClassifier.set(" javadoc" )
44
- if (! (isSnapshot || isSnapshot() || isSimbotLocal())) {
45
- dependsOn(tasks.dokkaGeneratePublicationHtml)
46
- from(tasks.dokkaGeneratePublicationHtml.flatMap { it.outputDirectory })
41
+ mavenPublishing {
42
+ publishToMavenCentral(SonatypeHost .CENTRAL_PORTAL )
43
+ if (! isSimbotLocal()) {
44
+ signAllPublications()
47
45
}
48
- }
46
+ coordinates(groupId = p.group.toString(), artifactId = p.name, version = p.version.toString())
49
47
50
- publishing {
51
- repositories {
52
- mavenLocal()
53
- if (isSnapshot) {
54
- configPublishMaven(SnapshotRepository )
55
- } else {
56
- configPublishMaven(ReleaseRepository )
48
+ pom {
49
+ name = p.name
50
+ description = p.description
51
+ url = P .HOMEPAGE
52
+ licenses {
53
+ P .licenses.forEach { license ->
54
+ license {
55
+ name ofIf license.name
56
+ url ofIf license.url
57
+ distribution ofIf license.distribution
58
+ comments ofIf license.comments
59
+ }
60
+ }
57
61
}
58
- }
59
62
60
- publications {
61
- withType<MavenPublication > {
62
- artifacts {
63
- artifact(jarJavadoc)
64
- }
63
+ val scm = P .scm
64
+ scm {
65
+ url ofIf scm.url
66
+ connection ofIf scm.connection
67
+ developerConnection ofIf scm.developerConnection
68
+ tag ofIf scm.tag
69
+ }
65
70
66
- setupPom(project.name, P )
71
+ developers {
72
+ P .developers.forEach { developer ->
73
+ developer {
74
+ id ofIf developer.id
75
+ name ofIf developer.name
76
+ email ofIf developer.email
77
+ url ofIf developer.url
78
+ organization ofIf developer.organization
79
+ organizationUrl ofIf developer.organizationUrl
80
+ timezone ofIf developer.timezone
81
+ roles.addAll(developer.roles)
82
+ properties.putAll(developer.properties)
83
+ }
84
+ }
67
85
}
68
86
}
69
87
}
70
88
71
- signing {
72
- val gpg = Gpg .ofSystemPropOrNull() ? : return @signing
73
- val (keyId, secretKey, password) = gpg
74
- useInMemoryPgpKeys(keyId, secretKey, password)
75
- sign(publishingExtension.publications)
76
- }
89
+ // val jarJavadoc by tasks.registering(Jar::class) {
90
+ // group = "documentation"
91
+ // archiveClassifier.set("javadoc")
92
+ // if (!(isSnapshot || isSnapshot() || isSimbotLocal())) {
93
+ // dependsOn(tasks.dokkaGeneratePublicationHtml)
94
+ // from(tasks.dokkaGeneratePublicationHtml.flatMap { it.outputDirectory })
95
+ // }
96
+ // }
97
+
98
+ // publishing {
99
+ // repositories {
100
+ // mavenLocal()
101
+ // if (isSnapshot) {
102
+ // configPublishMaven(SnapshotRepository)
103
+ // } else {
104
+ // configPublishMaven(ReleaseRepository)
105
+ // }
106
+ // }
107
+ //
108
+ // publications {
109
+ // withType<MavenPublication> {
110
+ // artifacts {
111
+ // artifact(jarJavadoc)
112
+ // }
113
+ //
114
+ // setupPom(project.name, P)
115
+ // }
116
+ // }
117
+ // }
118
+ //
119
+ // signing {
120
+ // val gpg = Gpg.ofSystemPropOrNull() ?: return@signing
121
+ // val (keyId, secretKey, password) = gpg
122
+ // useInMemoryPgpKeys(keyId, secretKey, password)
123
+ // sign(publishingExtension.publications)
124
+ // }
77
125
78
126
// TODO see https://github.com/gradle-nexus/publish-plugin/issues/208#issuecomment-1465029831
79
- val signingTasks: TaskCollection <Sign > = tasks.withType<Sign >()
80
- tasks.withType<PublishToMavenRepository >().configureEach {
81
- mustRunAfter(signingTasks)
82
- }
127
+ // val signingTasks: TaskCollection<Sign> = tasks.withType<Sign>()
128
+ // tasks.withType<PublishToMavenRepository>().configureEach {
129
+ // mustRunAfter(signingTasks)
130
+ // }
83
131
84
132
show()
85
133
0 commit comments