-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f52e969
commit 307e3f5
Showing
5 changed files
with
50 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,36 @@ | ||
import org.gradle.jvm.tasks.Jar | ||
import java.net.URI | ||
import com.vanniktech.maven.publish.SonatypeHost | ||
|
||
plugins { | ||
`maven-publish` | ||
signing | ||
} | ||
|
||
publishing { | ||
val javadocJar = project.configureEmptyJavadocArtifact() | ||
publications.withType(MavenPublication::class).all { | ||
pom.configureMavenCentralMetadata(project) | ||
signPublicationIfKeyPresent(project, this) | ||
artifact(javadocJar) | ||
} | ||
|
||
tasks.withType<PublishToMavenRepository>().configureEach { | ||
dependsOn(tasks.withType<Sign>()) | ||
} | ||
} | ||
|
||
// Pom configuration | ||
infix fun <T> Property<T>.by(value: T) { | ||
set(value) | ||
} | ||
|
||
fun MavenPom.configureMavenCentralMetadata(project: Project) { | ||
name by project.name | ||
description by "Kotlin/Multiplatform SDK for The Open Network" | ||
url by "https://github.com/ton-community/ton-kotlin" | ||
|
||
licenses { | ||
license { | ||
name by "The Apache Software License, Version 2.0" | ||
url by "https://www.apache.org/licenses/LICENSE-2.0.txt" | ||
distribution by "repo" | ||
id("com.vanniktech.maven.publish") | ||
} | ||
|
||
mavenPublishing { | ||
pom { | ||
name = project.name | ||
description = "Kotlin/Multiplatform SDK for The Open Network" | ||
inceptionYear = "2025" | ||
url = "https://github.com/ton-community/ton-kotlin" | ||
|
||
licenses { | ||
license { | ||
name = "The Apache Software License, Version 2.0" | ||
url = "https://www.apache.org/licenses/LICENSE-2.0.txt" | ||
distribution = "repo" | ||
} | ||
} | ||
} | ||
|
||
developers { | ||
developer { | ||
id by "andreypfau" | ||
name by "Andrey Pfau" | ||
email by "andreypfau@ton.org" | ||
developers { | ||
developer { | ||
id = "andreypfau" | ||
name = "Andrey Pfau" | ||
email = "andreypfau@ton.org" | ||
} | ||
} | ||
} | ||
|
||
scm { | ||
url by "https://github.com/ton-community/ton-kotlin" | ||
} | ||
} | ||
|
||
fun MavenPublication.mavenCentralArtifacts(project: Project, sources: SourceDirectorySet) { | ||
val sourcesJar by project.tasks.creating(Jar::class) { | ||
archiveClassifier.set("sources") | ||
from(sources) | ||
} | ||
val javadocJar by project.tasks.creating(Jar::class) { | ||
archiveClassifier.set("javadoc") | ||
// contents are deliberately left empty | ||
} | ||
artifact(sourcesJar) | ||
artifact(javadocJar) | ||
} | ||
|
||
|
||
fun mavenRepositoryUri(): URI { | ||
val repositoryId: String? = System.getenv("SONATYPE_REPOSITORY_ID") | ||
return if (repositoryId == null) { | ||
URI("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") | ||
} else { | ||
URI("https://s01.oss.sonatype.org/service/local/staging/deployByRepositoryId/$repositoryId") | ||
} | ||
} | ||
|
||
fun RepositoryHandler.configureMavenPublication(project: Project) { | ||
maven { | ||
url = mavenRepositoryUri() | ||
credentials { | ||
username = project.getSensitiveProperty("OSSRH_USERNAME") | ||
password = project.getSensitiveProperty("OSSRH_PASSWORD") | ||
} | ||
} | ||
|
||
mavenLocal() | ||
} | ||
|
||
fun Project.configureEmptyJavadocArtifact(): Jar { | ||
val javadocJar by project.tasks.creating(Jar::class) { | ||
archiveClassifier.set("javadoc") | ||
// contents are deliberately left empty | ||
} | ||
return javadocJar | ||
} | ||
|
||
fun signPublicationIfKeyPresent(project: Project, publication: MavenPublication) { | ||
val signingKey = project.getSensitiveProperty("SIGNING_SECRET_KEY") | ||
val signingKeyPassphrase = project.getSensitiveProperty("SIGNING_PASSWORD") | ||
if (!signingKey.isNullOrBlank()) { | ||
project.extensions.configure<SigningExtension>("signing") { | ||
useInMemoryPgpKeys(signingKey, signingKeyPassphrase) | ||
sign(publication) | ||
scm { | ||
url = "https://github.com/ton-community/ton-kotlin" | ||
} | ||
} | ||
} | ||
|
||
fun Project.getSensitiveProperty(name: String): String? { | ||
return project.findProperty(name) as? String ?: System.getenv(name) | ||
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) | ||
signAllPublications() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters