File tree Expand file tree Collapse file tree 2 files changed +34
-10
lines changed
json-schema-validator-bom Expand file tree Collapse file tree 2 files changed +34
-10
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,34 @@ val javadocJar by tasks.registering(Jar::class) {
9
9
10
10
fun getExtraString (name : String ) = ext[name]?.toString()
11
11
12
+ /* *
13
+ * Create a service for collecting the coordinates of all artifacts that should be included in the bom.
14
+ */
15
+ abstract class BomService : BuildService <BuildServiceParameters .None > {
16
+ /* * Coordinates that will be included in the BOM. */
17
+ abstract val coordinates: SetProperty <String >
18
+ }
19
+
20
+ val bomService: BomService =
21
+ gradle.sharedServices.registerIfAbsent(" bomService" , BomService ::class ).get()
22
+
23
+ extensions.add(" bomService" , bomService)
24
+
25
+ /* * Controls whether the current subproject will be included in the kotest-bom. */
26
+ val includeInBom: Property <Boolean > =
27
+ objects.property<Boolean >().convention(project.name != " json-schema-validator-bom" )
28
+
29
+ extensions.add<Property <Boolean >>(" includeInBom" , includeInBom)
30
+
31
+ bomService.coordinates
32
+ .addAll(
33
+ provider {
34
+ project.run { " $group :$name :$version " }
35
+ }.zip(includeInBom) { coordinates, include ->
36
+ if (include) listOf (coordinates) else emptyList()
37
+ },
38
+ )
39
+
12
40
afterEvaluate {
13
41
publishing {
14
42
Original file line number Diff line number Diff line change @@ -3,18 +3,14 @@ plugins {
3
3
convention.publication
4
4
}
5
5
6
- private val bomProjectName = name
7
-
8
6
configurations.api.configure {
9
7
dependencyConstraints.addAllLater(
10
- provider {
11
- rootProject.allprojects.filter {
12
- it.pluginManager.hasPlugin(" maven-publish" ) &&
13
- it.name != bomProjectName
14
- }.map {
15
- project.dependencies.constraints.create(" ${it.group} :${it.name} :${it.version} " )
16
- }
17
- },
8
+ bomService.coordinates
9
+ .map { coordinates ->
10
+ coordinates
11
+ .distinct()
12
+ .map(project.dependencies.constraints::create)
13
+ },
18
14
)
19
15
}
20
16
You can’t perform that action at this time.
0 commit comments