1818 * If not, see <https://www.gnu.org/licenses/>.
1919 */
2020
21- import love.forte.gradle.common.core.Gpg
21+ import com.vanniktech.maven.publish.SonatypeHost
2222import love.forte.gradle.common.core.project.setup
23+ import love.forte.gradle.common.core.property.ofIf
2324import 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
2726
2827plugins {
2928 kotlin(" multiplatform" )
3029 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" )
3232 id(" org.jetbrains.dokka" )
3333}
3434
@@ -38,48 +38,96 @@ setup(P)
3838val p = project
3939val isSnapshot = project.version.toString().contains(" SNAPSHOT" , true )
4040
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()
4745 }
48- }
46+ coordinates(groupId = p.group.toString(), artifactId = p.name, version = p.version.toString())
4947
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+ }
5761 }
58- }
5962
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+ }
6570
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+ }
6785 }
6886 }
6987}
7088
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+ // }
77125
78126// 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+ // }
83131
84132show()
85133
0 commit comments