Skip to content

Commit

Permalink
fix: configure publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
FunkyMuse committed Jan 22, 2024
1 parent 41cea2a commit 9e3a991
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class KotlinLibraryConventionPlugin : Plugin<Project> {
apply(versionCatalog.getPluginId("java-library"))
apply(versionCatalog.getPluginId("kotlinJvm"))
apply(versionCatalog.getPluginId("dokka"))
apply(versionCatalog.getVersion("gradlePlugins-maven-publish"))
}
configureJava {
toolchain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class LibraryConventionPlugin : Plugin<Project> {
apply(versionCatalog.getPluginId("kotlinAndroid"))
apply(versionCatalog.getPluginId("spotless"))
apply(versionCatalog.getPluginId("dokka"))
apply(versionCatalog.getVersion("gradlePlugins-maven-publish"))
}
configureKotlinOptions()
configureLibraryAndTestNameSpace()
Expand Down
37 changes: 36 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import com.diffplug.gradle.spotless.SpotlessPlugin
import com.android.build.gradle.LibraryPlugin

plugins {
id(libs.versions.gradlePlugins.maven.publish.get())
alias(libs.plugins.android).apply(false)
alias(libs.plugins.library).apply(false)
alias(libs.plugins.kotlinAndroid).apply(false)
Expand Down Expand Up @@ -63,4 +65,37 @@ allprojects {
}
}
}
}
}

subprojects {
plugins.matching { anyPlugin -> supportedPlugins(anyPlugin) }.whenPluginAdded {
apply(plugin = libs.versions.gradlePlugins.maven.publish.get())
plugins.withType<JavaLibraryPlugin> {
publishing.publications {
create<MavenPublication>("kotlin") {
artifactId = this@subprojects.name
version = libs.versions.app.version.versionName.get()
afterEvaluate {
from(components["kotlin"])
}
}
}
}
plugins.withType<LibraryPlugin> {
afterEvaluate {
publishing.publications {
create<MavenPublication>("release") {
artifactId = this@subprojects.name
version = libs.versions.app.version.versionName.get()
afterEvaluate {
from(components["release"])
}
}
}
}
}
}
}

fun supportedPlugins(anyPlugin: Plugin<*>?) =
anyPlugin is LibraryPlugin || anyPlugin is JavaLibraryPlugin

0 comments on commit 9e3a991

Please sign in to comment.