|
| 1 | +import com.github.ajalt.mordant.rendering.TextColors.* |
1 | 2 | import common.*
|
2 | 3 | import org.gradle.kotlin.dsl.*
|
3 | 4 |
|
4 |
| -@Suppress("UNUSED_VARIABLE") |
5 | 5 | 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 | + } |
25 | 17 |
|
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)) |
31 | 20 |
|
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 | + } |
33 | 34 | }
|
| 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 | + } |
34 | 65 |
|
35 | 66 | // val versionCatalog = the<VersionCatalogsExtension>().named("libs")
|
36 | 67 |
|
|
0 commit comments