1+ import  java.io.FileInputStream 
2+ import  java.util.Properties 
3+ 
14plugins {
25    `maven- publish`
36    signing
47}
58
9+ val  javadocJar by tasks.registering(Jar ::class ) {
10+     archiveClassifier.set(" javadoc"  )
11+ }
12+ 
613val  githubUrl =  " https://github.com" 
714val  projectUrl =  " $githubUrl /miuix-kotlin-multiplatform/miuix" 
815
916publishing {
17+     //  Configure the publication repository
18+     repositories {
19+         maven {
20+             url =  uri(layout.buildDirectory.dir(" repo"  ))
21+         }
22+     }
23+     //  Configure all publications
1024    publications.withType<MavenPublication > {
1125        //  Stub javadoc.jar artifact
12-         artifact(tasks.register(" ${name} JavadocJar"  , Jar ::class ) {
13-             archiveClassifier.set(" javadoc"  )
14-             archiveAppendix.set(this @withType.name)
15-         })
16- 
17-         //  Provide artifacts information required by Maven Central
26+         artifact(javadocJar.get())
27+         //  Provide artifacts information required
1828        pom {
1929            name.set(" miuix"  )
2030            description.set(" A UI library for Compose MultiPlatform"  )
@@ -52,15 +62,24 @@ publishing {
5262            }
5363        }
5464    }
55- 
56-     repositories {
57-         maven {
58-             url =  uri(layout.buildDirectory.dir(" repo"  ))
59-         }
60-     }
6165}
6266
67+ //  Signing artifacts. Signing.* extra properties values will be used
6368signing {
64-     useGpgCmd()
69+     val  localPropertiesFile =  project.rootProject.file(" local.properties"  )
70+     val  localProperties =  Properties ()
71+     if  (localPropertiesFile.exists()) {
72+         FileInputStream (localPropertiesFile).use { fis -> 
73+             localProperties.load(fis)
74+         }
75+     }
76+     val  signingKey =  localProperties.getProperty(" GPG_SIGNING_KEY"  ) ? :  System .getenv(" GPG_SIGNING_KEY"  )
77+     val  signingPassword =  localProperties.getProperty(" GPG_SIGNING_KEY"  ) ? :  System .getenv(" GPG_PASSPHRASE"  )
78+     useInMemoryPgpKeys(signingKey, signingPassword)
6579    sign(publishing.publications)
6680}
81+ 
82+ //  Ensure all publish tasks depend on corresponding sign tasks
83+ tasks.withType<PublishToMavenRepository >().configureEach {
84+     dependsOn(tasks.withType<Sign >())
85+ }
0 commit comments