diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index e6ed95d..2cfbb20 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -18,6 +18,7 @@ dependencies { compileOnly(libs.android.gradle.plugin) compileOnly(libs.android.tools.common) compileOnly(libs.kotlin.gradle.plugin) + compileOnly(libs.maven.publish) } gradlePlugin { diff --git a/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt index 4bbcb46..348fe42 100644 --- a/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt @@ -1,4 +1,6 @@ import com.android.build.gradle.LibraryExtension +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import com.vanniktech.maven.publish.SonatypeHost import org.gradle.api.JavaVersion import org.gradle.api.Plugin import org.gradle.api.Project @@ -12,6 +14,7 @@ class AndroidLibraryConventionPlugin : Plugin { with(pluginManager) { apply("com.android.library") apply("org.jetbrains.kotlin.multiplatform") + apply("com.vanniktech.maven.publish") } configure { @@ -19,7 +22,7 @@ class AndroidLibraryConventionPlugin : Plugin { publishLibraryVariants("release") compilations.all { kotlinOptions { - jvmTarget = "17" + jvmTarget = JavaVersion.VERSION_1_8.toString() } } } @@ -38,8 +41,39 @@ class AndroidLibraryConventionPlugin : Plugin { minSdk = 21 } compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + } + + configure { + publishToMavenCentral(SonatypeHost.DEFAULT) + signAllPublications() + + pom { + name.set("requireKTX") + description.set("Kotlin utilities for easily grabbing required values") + inceptionYear.set("2020") + url.set("https://github.com/zsmb13/requireKTX") + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + developers { + developer { + id.set("zsmb13") + name.set("Márton Braun") + email.set("braunmarci@gmail.com") + } + } + scm { + connection.set("scm:git:github.com/zsmb13/requireKTX.git") + developerConnection.set("scm:git:ssh://github.com/zsmb13/requireKTX.git") + url.set("https://github.com/zsmb13/requireKTX/tree/main") + } } } } diff --git a/build.gradle.kts b/build.gradle.kts index f6b28a4..57a273d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,4 +2,5 @@ plugins { alias(libs.plugins.androidApplication) apply false alias(libs.plugins.androidLibrary) apply false alias(libs.plugins.kotlinMultiplatform) apply false + alias(libs.plugins.mavenPublish) apply false } diff --git a/gradle.properties b/gradle.properties index 2521752..9c0fdc2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,8 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true # Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official \ No newline at end of file +kotlin.code.style=official + +# Publishing +group=co.zsmb +version=1.3.0 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7c3fe76..d30ed6c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,6 +8,7 @@ junit = "4.13.2" junit-jupiter-api = "5.9.2" kotlin = "1.9.24" material = "1.12.0" +maven-publish = "0.28.0" navigation-runtime = "2.7.7" robolectric = "4.12.1" work-runtime = "2.9.0" @@ -25,6 +26,7 @@ junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", vers kotlin-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } material = { module = "com.google.android.material:material", version.ref = "material" } +maven-publish = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "maven-publish" } navigation-runtime = { module = "androidx.navigation:navigation-runtime", version.ref = "navigation-runtime" } robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } work-runtime = { module = "androidx.work:work-runtime", version.ref = "work-runtime" } @@ -33,4 +35,5 @@ work-runtime = { module = "androidx.work:work-runtime", version.ref = "work-runt androidApplication = { id = "com.android.application", version.ref = "agp" } androidLibrary = { id = "com.android.library", version.ref = "agp" } kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +mavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish" } requireKtxLibrary = { id = "co.zsmb.requirektx.library", version = "unspecified" }