Skip to content

Commit 101b085

Browse files
committed
chore: build plugin minor refactorings
1 parent 433b508 commit 101b085

File tree

5 files changed

+63
-28
lines changed

5 files changed

+63
-28
lines changed

gradle/build-logic/src/main/kotlin/dev.suresh.plugin.common.gradle.kts

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,67 @@
1+
import com.github.ajalt.mordant.rendering.TextColors.*
12
import common.*
23
import org.gradle.kotlin.dsl.*
34

4-
@Suppress("UNUSED_VARIABLE")
55
tasks {
6-
val copyTemplates by
7-
registering(Copy::class) {
8-
description = "Generate template classes"
9-
group = LifecycleBasePlugin.BUILD_GROUP
10-
11-
// val props = project.properties.toMutableMap()
12-
val props = mutableMapOf<String, Any?>()
13-
props["git_branch"] = project.findProperty("branch_name")
14-
props["git_tag"] = project.findProperty("base_tag")
15-
16-
// Add info from the Gradle version catalog
17-
val versionCatalog = project.catalogs.named("libs")
18-
props["javaVersion"] = versionCatalog.findVersion("java").get()
19-
props["kotlinVersion"] = versionCatalog.findVersion("kotlin").get()
20-
props["gradleVersion"] = versionCatalog.findVersion("gradle").get()
21-
22-
if (debugEnabled) {
23-
props.forEach { (t, u) -> println("%1\$-42s --> %2\$s".format(t, u)) }
24-
}
6+
register("printArtifacts") {
7+
doLast {
8+
val configsWithArtifacts =
9+
configurations
10+
.filter { it.isCanBeResolved || it.isCanBeConsumed }
11+
.filter { it.outgoing.artifacts.isNotEmpty() }
12+
13+
if (configsWithArtifacts.isEmpty()) {
14+
logger.lifecycle(yellow("No configurations with outgoing artifacts found"))
15+
return@doLast
16+
}
2517

26-
filteringCharset = Charsets.UTF_8.name()
27-
from(project.projectDir.resolve("src/main/templates"))
28-
into(project.layout.buildDirectory.dir("generated-sources/templates/kotlin/main"))
29-
exclude { it.name.startsWith("jte") }
30-
expand(props)
18+
logger.lifecycle(magenta("\n📦 Outgoing Artifacts Report"))
19+
logger.lifecycle("".repeat(28))
3120

32-
// inputs.property("buildversions", props.hashCode())
21+
configsWithArtifacts.forEach { config ->
22+
logger.lifecycle("")
23+
logger.lifecycle("📎 Configuration: ${green(config.name)}")
24+
logger.lifecycle("├─ Consumable: ${config.isCanBeConsumed}")
25+
logger.lifecycle("├─ Resolvable: ${config.isCanBeResolved}")
26+
logger.lifecycle("└─ Artifacts:")
27+
28+
config.outgoing.artifacts.forEachIndexed { index, artifact ->
29+
val isLast = index == config.outgoing.artifacts.size - 1
30+
val prefix = if (isLast) " └─" else " ├─"
31+
logger.lifecycle(
32+
"$prefix ${cyan(artifact.file.name)} (${artifact.file.length().byteDisplaySize()})")
33+
}
3334
}
35+
}
36+
}
37+
38+
register<Copy>("copyTemplates") {
39+
description = "Generate template classes"
40+
group = LifecycleBasePlugin.BUILD_GROUP
41+
42+
// val props = project.properties.toMutableMap()
43+
val props = mutableMapOf<String, Any?>()
44+
props["git_branch"] = project.findProperty("branch_name")
45+
props["git_tag"] = project.findProperty("base_tag")
46+
47+
// Add info from the Gradle version catalog
48+
val versionCatalog = project.catalogs.named("libs")
49+
props["javaVersion"] = versionCatalog.findVersion("java").get()
50+
props["kotlinVersion"] = versionCatalog.findVersion("kotlin").get()
51+
props["gradleVersion"] = versionCatalog.findVersion("gradle").get()
52+
53+
if (debugEnabled) {
54+
props.forEach { (t, u) -> println("%1\$-42s --> %2\$s".format(t, u)) }
55+
}
56+
57+
filteringCharset = Charsets.UTF_8.name()
58+
from(project.projectDir.resolve("src/main/templates"))
59+
into(project.layout.buildDirectory.dir("generated-sources/templates/kotlin/main"))
60+
exclude { it.name.startsWith("jte") }
61+
expand(props)
62+
63+
// inputs.property("buildversions", props.hashCode())
64+
}
3465

3566
// val versionCatalog = the<VersionCatalogsExtension>().named("libs")
3667

gradle/build-logic/src/main/kotlin/dev.suresh.plugin.kotlin.jvm.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ plugins {
2323
dev.zacsweers.redacted
2424
com.javiersc.kotlin.kopy
2525
org.jetbrains.kotlinx.atomicfu
26+
id("dev.suresh.plugin.common")
2627
id("dev.suresh.plugin.kotlin.docs")
2728
// kotlin("plugin.atomicfu")
2829
// `test-suite-base`

gradle/build-logic/src/main/kotlin/dev.suresh.plugin.kotlin.mpp.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ plugins {
2020
kotlin("plugin.serialization")
2121
kotlin("plugin.power-assert")
2222
kotlin("plugin.js-plain-objects")
23+
id("dev.suresh.plugin.common")
2324
id("dev.suresh.plugin.kotlin.docs")
2425
com.google.devtools.ksp
2526
dev.zacsweers.redacted

gradle/build-logic/src/main/kotlin/dev.suresh.plugin.root.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import org.gradle.api.publish.plugins.PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NA
55
import org.gradle.kotlin.dsl.*
66

77
plugins {
8-
id("dev.suresh.plugin.common")
98
idea
109
wrapper
1110
id("dev.suresh.plugin.kotlin.docs")

gradle/libs.versions.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ org-name = "suresh.dev"
2020
org-url = "https://suresh.dev"
2121

2222
# Gradle Dependencies Versions
23-
bc-plugins = "1.11.0"
23+
bc-plugins = "1.12.0"
2424
kotlinx-kover = "0.9.1"
2525
kotlinx-bcv = "0.17.0"
2626
kotlin-dokka = "2.0.0"
@@ -170,6 +170,7 @@ chasm = "0.9.53"
170170
cel = "0.9.1"
171171
kfswatch = "1.3.0"
172172
kmp-process = "0.1.2"
173+
kmbed = "1.8.4"
173174
langchain4j = "1.0.0-beta1"
174175
jlama = "0.8.4"
175176
mcp-kotlin = "0.3.0"
@@ -652,6 +653,7 @@ kmp-process = { module = "io.matthewnelson.kmp-process:
652653
log4k-coroutines = { module = "io.github.smyrgeorge:log4k-coroutines" , version.ref = "log4k" }
653654
log4k-slf4j = { module = "io.github.smyrgeorge:log4k-slf4j" , version.ref = "log4k" }
654655
rwmutex = { module = "com.mayakapps.rwmutex:rwmutex" , version.ref = "rwmutex" }
656+
kmbed-runtime = { module = "io.karma.kmbed:kmbed-runtime" , version.ref = "kmbed" }
655657

656658
# Wasm
657659
chicory = { module = "com.dylibso.chicory:runtime" , version.ref = "chicory" }
@@ -754,6 +756,7 @@ poko = { id = "dev.drewhamilton.poko"
754756
mcp4k = { id = "sh.ondr.mcp4k" , version.ref = "mcp4k"}
755757
animalsniffer = { id = "ru.vyarus.animalsniffer" , version.ref = "animalsniffer"}
756758
build-vercraft = { id = "com.akuleshov7.vercraft.plugin-gradle" , version.ref = "vercraft" }
759+
kmbed-plugin = { id = "io.karma.kmbed.kmbed-gradle-plugin" , version.ref = "kmbed" }
757760

758761
# Common build and settings plugin
759762
project-root = { id = "dev.suresh.plugin.root" , version.ref = "bc-plugins" }

0 commit comments

Comments
 (0)