Skip to content

Commit

Permalink
Merge branch 'develop' into feat/logging/colorful
Browse files Browse the repository at this point in the history
  • Loading branch information
testersen authored Apr 1, 2024
2 parents 1e14e5b + 8c45934 commit 5368b0f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
10 changes: 7 additions & 3 deletions buildSrc/src/main/kotlin/io/tnboot/gradle/build/PublishPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class PublishPlugin : Plugin<Project> {
}
}

open class Extension {
open class Extension(
private val project: Project,
) {
var enabled = true
var evenWithChildren = false

Expand All @@ -37,13 +39,15 @@ class PublishPlugin : Plugin<Project> {
fun configure(block: MavenPublication.() -> Unit) {
configurations.add(block)
}

val isPublished get() = enabled && (evenWithChildren || project.childProjects.isEmpty())
}

override fun apply(target: Project) {
target.extensions.add(Extension::class.java, "publish", Extension())
target.extensions.add(Extension::class.java, "publish", Extension(target))
target.afterEvaluate {
target.extensions.getByType(Extension::class.java).let { extension ->
if (!extension.enabled || (target.childProjects.isNotEmpty() && !extension.evenWithChildren)) return@afterEvaluate
if (!extension.isPublished) return@afterEvaluate
log.debug("Enabling Maven Publications for project {}", target.name)
target.mavenPublish {
extension.configurations.forEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ fun Project.mavenPublish(block: MavenPublication.() -> Unit) {
}
}
}

val Project.publishedProjects get() = rootProject.allprojects.filter {
it != project && it.plugins.hasPlugin(PublishPlugin::class.java) &&
it.extensions.getByType(PublishPlugin.Extension::class.java).isPublished
}

val Project.notation get() = "$group:$name:$version"
3 changes: 3 additions & 0 deletions telenor-boot-dependencies/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import io.tnboot.gradle.build.DependencyGroups
import io.tnboot.gradle.build.mavenPublish
import io.tnboot.gradle.build.notation
import io.tnboot.gradle.build.publishedProjects

plugins {
`java-platform`
Expand All @@ -15,6 +17,7 @@ val bom = DependencyGroups(
dependencies {
constraints {
bom.dependencies.forEach { add("api", it) }
publishedProjects.forEach { add("api", it.notation) }
}
}

Expand Down

0 comments on commit 5368b0f

Please sign in to comment.