Skip to content

Commit 8dea05f

Browse files
committed
chore: dep reports plugin and misc changes
1 parent 6128aeb commit 8dea05f

File tree

8 files changed

+107
-8
lines changed

8 files changed

+107
-8
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,19 @@ $ ./gradlew ciBuild
3535
$ ./gradlew :common:run
3636
$ ./gradlew :backend:run
3737
$ ./gradlew :web:jsBrowserProductionRun -t
38-
$ ./gradlew :benchmarks:benchmark
38+
39+
# Publishing
3940
$ ./gradlew publishAllPublicationsToLocalRepository
41+
42+
# Benchmark
43+
$ ./gradlew :benchmarks:benchmark
44+
45+
# Dependency Graph
46+
$ ./gradlew :backend:listResolvedArtifacts
4047
$ ./gradlew createModuleGraph
48+
49+
# GitHub Actions lint
50+
$ actionlint
4151
```
4252

4353
</details>

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ org.gradle.caching=true
55
org.gradle.daemon=false
66
org.gradle.configureondemand=true
77
org.gradle.configuration-cache=false
8+
org.gradle.kotlin.dsl.allWarningsAsErrors=true
89
# org.gradle.configuration-cache.problems=warn
910
# org.gradle.configuration-cache.max-problems=5
10-
org.gradle.kotlin.dsl.allWarningsAsErrors=true
1111
# org.gradle.welcome=never
1212
# org.gradle.console=rich
1313
# org.gradle.debug=true
@@ -41,8 +41,8 @@ ksp.version.check=false
4141
# Project
4242
semver.project.tagPrefix=v
4343
semver.checkClean=false
44+
semver.commitsMaxCount=100
4445
# semver.tagPrefix=v
4546
# semver.stage=final
4647
# semver.scope=patch
47-
semver.commitsMaxCount=100
48-
debug=false
48+
debug=false

gradle/build-logic/common-plugins/build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ gradlePlugin {
6464
tags = listOf("Generic Plugin", "build-logic")
6565
}
6666

67+
// Dependency Reports plugin
68+
register("Dependency Reports") {
69+
id = "plugins.dependency.reports"
70+
implementationClass = "plugins.DepReportsPlugin"
71+
displayName = "Dependency Reports plugin"
72+
description = "A plugin to list all the resolved artifacts"
73+
tags = listOf("Dependency Reports", "build-logic")
74+
}
75+
6776
// Uncomment the id to change plugin id for this pre-compiled plugin
6877
named("plugins.common") {
6978
// id = "build.plugins.common"
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package plugins
2+
3+
import org.gradle.api.DefaultTask
4+
import org.gradle.api.Plugin
5+
import org.gradle.api.Project
6+
import org.gradle.api.artifacts.component.ComponentArtifactIdentifier
7+
import org.gradle.api.artifacts.result.ResolvedArtifactResult
8+
import org.gradle.api.artifacts.result.ResolvedVariantResult
9+
import org.gradle.api.file.RegularFile
10+
import org.gradle.api.file.RegularFileProperty
11+
import org.gradle.api.provider.ListProperty
12+
import org.gradle.api.tasks.*
13+
import org.gradle.kotlin.dsl.*
14+
15+
/**
16+
* The plugin to resolve runtime dependencies and generate reports.
17+
*
18+
* [Accessing the resolution result
19+
* programmatically](https://docs.gradle.org/current/userguide/dependency_resolution.html#sec:programmatic_api)
20+
*/
21+
class DepReportsPlugin : Plugin<Project> {
22+
override fun apply(target: Project) =
23+
with(target) {
24+
pluginManager.withPlugin("java-base") {
25+
val listResolvedArtifacts by
26+
tasks.registering(ListResolvedArtifacts::class) {
27+
// Get the runtime resolved artifacts
28+
val runtimeClasspath by target.configurations
29+
val resolvedArtifacts = runtimeClasspath.incoming.artifacts.resolvedArtifacts
30+
31+
// Transform the artifacts
32+
artifactIds.set(resolvedArtifacts.map { it.map(ResolvedArtifactResult::getId) })
33+
artifactVariants.set(
34+
resolvedArtifacts.map { it.map(ResolvedArtifactResult::getVariant) })
35+
artifactFiles.set(
36+
resolvedArtifacts.map {
37+
it.map { resolvedArtifactResult ->
38+
layout.projectDirectory.file(resolvedArtifactResult.file.absolutePath)
39+
}
40+
})
41+
outputFile.convention(layout.buildDirectory.file("resolved-artifacts.txt"))
42+
}
43+
}
44+
}
45+
}
46+
47+
@CacheableTask
48+
abstract class ListResolvedArtifacts : DefaultTask() {
49+
50+
@get:Input abstract val artifactIds: ListProperty<ComponentArtifactIdentifier>
51+
52+
@get:Input abstract val artifactVariants: ListProperty<ResolvedVariantResult>
53+
54+
@get:InputFiles
55+
@get:PathSensitive(PathSensitivity.RELATIVE)
56+
abstract val artifactFiles: ListProperty<RegularFile>
57+
58+
@get:OutputFile abstract val outputFile: RegularFileProperty
59+
60+
@TaskAction
61+
fun execute() {
62+
val ids = artifactIds.get()
63+
val variants = artifactVariants.get()
64+
val files = artifactFiles.get()
65+
val outFile = outputFile.asFile.get()
66+
67+
outFile.bufferedWriter().use {
68+
ids.forEachIndexed { idx, id ->
69+
val variant = variants[idx]
70+
val file = files[idx]
71+
it.appendLine("FILE ${file.asFile.name}")
72+
it.appendLine(" id: ${id.displayName}")
73+
it.appendLine(" variant: ${variant.displayName}")
74+
it.appendLine(" size: ${file.asFile.length()}")
75+
it.appendLine()
76+
}
77+
}
78+
outFile.forEachLine { println(it) }
79+
}
80+
}

gradle/build-logic/common-plugins/src/main/kotlin/plugins/kotlin.jvm.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ plugins {
1717
// `test-suite-base`
1818
}
1919

20+
// Apply the regular plugin
21+
apply(plugin = "plugins.dependency.reports")
22+
2023
java {
2124
withSourcesJar()
2225
withJavadocJar()

gradle/build-logic/common-plugins/src/main/kotlin/tasks/ReallyExecJar.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ abstract class ReallyExecJar : DefaultTask() {
2929
description = "Build executable binary"
3030
group = LifecycleBasePlugin.BUILD_TASK_NAME
3131
javaOpts.convention(emptyList())
32-
// Default executable file name would be the project name.
3332
execJarFile.convention(project.layout.buildDirectory.file(project.name))
3433
}
3534

gradle/build-logic/gradle.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ org.gradle.daemon=false
66
org.gradle.configureondemand=true
77
org.gradle.configuration-cache=true
88
org.gradle.configuration-cache.problems=warn
9-
org.gradle.configuration-cache.max-problems=5
109
org.gradle.kotlin.dsl.allWarningsAsErrors=true
1110

1211
## Kotlin
1312
kotlin.code.style=official
14-
# kotlin.experimental.tryK2=true
1513
kotlin.daemon.jvmargs=--show-version --enable-preview
1614
# https://kotl.in/gradle/jvm/target-validation
1715
kotlin.jvm.target.validation.mode=warning

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ graalvm = "23.0.0"
6767
rsocket = "0.15.4"
6868
jctools = "4.0.1"
6969
compose-icons = "1.1.0"
70-
benasher44-uuid = "0.7.1"
70+
benasher44-uuid = "0.8.0"
7171
kotlinx-uuid = "0.0.20"
7272
kotlin-codepoints = "0.6.1"
7373
kotlin-logging = "5.0.0"

0 commit comments

Comments
 (0)