-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from CharLEE-X/lint_and_publish
Lint and publish
- Loading branch information
Showing
11 changed files
with
99 additions
and
225 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import org.gradle.api.JavaVersion | ||
|
||
/* | ||
* Copyright (c) 2023 Adrian Witaszak - CharLEE-X. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
object AppConfig { | ||
const val projectName = "NotifiKations" | ||
const val groupId = "com.charleex" | ||
const val artifactId = "notifikations" | ||
const val version = "0.0.1" | ||
const val description = "Kotlin Multiplatform library (Android + iOS)" | ||
const val url = "https://github.com/CharLEE-X/notifiKations" | ||
|
||
object Developer { | ||
const val id = "charlee-dev" | ||
const val name = "Adrian Witaszak" | ||
const val email = "[email protected]" | ||
} | ||
|
||
object Licence { | ||
const val name = "Apache 2.0 license" | ||
const val url = "https://www.apache.org/licenses/LICENSE-2.0" | ||
} | ||
|
||
const val iosDevelopmentTarget = "14.1" | ||
|
||
const val jvmTargetInt = 17 | ||
const val jvmTarget = jvmTargetInt.toString() | ||
|
||
const val androidMinSdk = 26 | ||
const val androidCompileSdk = 33 | ||
const val androidTargetSdk = androidCompileSdk | ||
val javaVersion = JavaVersion.VERSION_17 | ||
} |
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 |
---|---|---|
|
@@ -10,14 +10,11 @@ plugins { | |
id("org.jetbrains.dokka") | ||
} | ||
|
||
// Stub secrets to let the project sync and build without the publication values set up | ||
ext["signing.keyId"] = null | ||
ext["signing.key"] = null | ||
ext["signing.password"] = null | ||
ext["signing.secretKeyRingFile"] = null | ||
ext["ossrhUsername"] = null | ||
ext["ossrhPassword"] = null | ||
|
||
// Grabbing secrets from local.properties file or from environment variables, which could be used on CI | ||
val secretPropsFile = project.rootProject.file("local.properties") | ||
if (secretPropsFile.exists()) { | ||
secretPropsFile.reader().use { | ||
|
@@ -28,9 +25,8 @@ if (secretPropsFile.exists()) { | |
ext[name.toString()] = value | ||
} | ||
} else { | ||
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID") | ||
ext["signing.key"] = System.getenv("SIGNING_KEY") | ||
ext["signing.password"] = System.getenv("SIGNING_PASSWORD") | ||
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE") | ||
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME") | ||
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD") | ||
} | ||
|
@@ -39,53 +35,62 @@ val javadocJar by tasks.registering(Jar::class) { | |
archiveClassifier.set("javadoc") | ||
} | ||
|
||
fun getExtraString(name: String) = ext[name]?.toString() | ||
val signingTasks = tasks.withType<Sign>() | ||
tasks.withType<AbstractPublishToMaven>().configureEach { | ||
dependsOn(signingTasks) | ||
} | ||
|
||
publishing { | ||
// Configure maven central repository | ||
repositories { | ||
maven { | ||
name = "sonatype" | ||
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") | ||
credentials { | ||
username = getExtraString("ossrhUsername") | ||
password = getExtraString("ossrhPassword") | ||
afterEvaluate { | ||
publishing { | ||
repositories { | ||
maven { | ||
name = "sonatype" | ||
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") | ||
credentials { | ||
username = getExtraString("ossrhUsername") | ||
password = getExtraString("ossrhPassword") | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Configure all publications | ||
publications.withType<MavenPublication> { | ||
// Stub javadoc.jar artifact | ||
artifact(javadocJar.get()) | ||
publications.withType<MavenPublication> { | ||
artifact(javadocJar.get()) | ||
|
||
// Provide artifacts information requited by Maven Central | ||
pom { | ||
name.set("MPP Sample library") | ||
description.set("Sample Kotlin Multiplatform library (jvm + ios + js) test") | ||
url.set("https://github.com/<your-github-repo>/mpp-sample-lib") | ||
pom { | ||
name.set(AppConfig.projectName) | ||
description.set(AppConfig.description) | ||
url.set(AppConfig.url) | ||
|
||
licenses { | ||
license { | ||
name.set("MIT") | ||
url.set("https://opensource.org/licenses/MIT") | ||
licenses { | ||
license { | ||
name.set(AppConfig.Licence.name) | ||
url.set(AppConfig.Licence.url) | ||
} | ||
} | ||
} | ||
developers { | ||
developer { | ||
id.set("charlee-dev") | ||
name.set("Adrian Witaszak") | ||
email.set("[email protected]") | ||
developers { | ||
developer { | ||
id.set(AppConfig.Developer.id) | ||
name.set(AppConfig.Developer.name) | ||
email.set(AppConfig.Developer.email) | ||
} | ||
} | ||
scm { | ||
url.set(AppConfig.url) | ||
} | ||
} | ||
scm { | ||
url.set("https://github.com/<your-github-repo>/mpp-sample-lib") | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Signing artifacts. Signing.* extra properties values will be used | ||
signing { | ||
useInMemoryPgpKeys( | ||
getExtraString("signing.key"), | ||
getExtraString("signing.password") | ||
) | ||
sign(publishing.publications) | ||
} | ||
|
||
fun getExtraString(name: String): String = ext[name]?.toString() | ||
?: findProperty(name)?.toString() | ||
?: System.getenv(name)?.toString() | ||
?: error("Property '$name' not found") |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -8,10 +8,7 @@ plugins { | |
kotlin("multiplatform") | ||
id("com.android.library") | ||
kotlin("plugin.serialization") | ||
// id("convention.publication") | ||
id("org.jetbrains.dokka") version "1.8.20" | ||
id("maven-publish") | ||
id("signing") | ||
id("convention.publication") | ||
} | ||
|
||
group = ProjectConfig.groupId + ".${ProjectConfig.artifactId}" | ||
|
@@ -21,7 +18,7 @@ kotlin { | |
jvmToolchain(ProjectConfig.jvmTargetInt) | ||
|
||
android { | ||
publishLibraryVariants("release") | ||
publishAllLibraryVariants() | ||
} | ||
ios { | ||
binaries { | ||
|
@@ -74,93 +71,6 @@ android { | |
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
publishing { | ||
singleVariant("release") { | ||
withSourcesJar() | ||
withJavadocJar() | ||
} | ||
} | ||
} | ||
|
||
tasks.check.dependsOn(tasks.detektAll) | ||
|
||
val dokkaOutputDir = "$buildDir/dokka" | ||
|
||
tasks.dokkaHtml { | ||
outputDirectory.set(file(dokkaOutputDir)) | ||
} | ||
|
||
val deleteDokkaOutputDir by tasks.register<Delete>("deleteDokkaOutputDirectory") { | ||
delete(dokkaOutputDir) | ||
} | ||
|
||
val javadocJar = tasks.register<Jar>("javadocJar") { | ||
dependsOn(deleteDokkaOutputDir, tasks.dokkaHtml) | ||
archiveClassifier.set("javadoc") | ||
from(dokkaOutputDir) | ||
} | ||
|
||
publishing { | ||
repositories { | ||
maven { | ||
name = "Sonatype" | ||
setUrl { | ||
val repositoryId = | ||
System.getenv("SONATYPE_REPOSITORY_ID") ?: error("Missing env variable: SONATYPE_REPOSITORY_ID") | ||
"https://oss.sonatype.org/service/local/staging/deployByRepositoryId/${repositoryId}/" | ||
} | ||
credentials { | ||
username = System.getenv("SONATYPE_USERNAME") | ||
password = System.getenv("SONATYPE_PASSWORD") | ||
} | ||
} | ||
maven { | ||
name = "Snapshot" | ||
setUrl { "https://oss.sonatype.org/content/repositories/snapshots/" } | ||
credentials { | ||
username = System.getenv("SONATYPE_USERNAME") | ||
password = System.getenv("SONATYPE_PASSWORD") | ||
} | ||
} | ||
} | ||
|
||
publications { | ||
withType<MavenPublication> { | ||
artifact(javadocJar) | ||
pom { | ||
name.set(ProjectConfig.projectName) | ||
description.set(ProjectConfig.description) | ||
url.set(ProjectConfig.url) | ||
licenses { | ||
license { | ||
name.set("MIT license") | ||
url.set("https://opensource.org/licenses/MIT") | ||
} | ||
} | ||
issueManagement { | ||
system.set("Github") | ||
url.set("https://github.com/CharLEE-X/notifiKations/issues") | ||
} | ||
scm { | ||
connection.set("https://github.com/CharLEE-X/notifiKations.git") | ||
url.set("") | ||
} | ||
developers { | ||
developer { | ||
name.set("Adrian Witaszak") | ||
id.set("charlee-dev") | ||
email.set("[email protected]") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
useInMemoryPgpKeys( | ||
System.getenv("GPG_PRIVATE_KEY"), | ||
System.getenv("GPG_PRIVATE_PASSWORD") | ||
) | ||
sign(publishing.publications) | ||
} |
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
Oops, something went wrong.