Skip to content

Commit fc0996c

Browse files
authored
enhancement: add BOM module (#268)
Resolves #265
1 parent 1082f55 commit fc0996c

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ allprojects {
1111
}
1212

1313
apiValidation {
14-
ignoredProjects += listOf("benchmark", "test-suites")
14+
ignoredProjects += listOf("benchmark", "test-suites", "json-schema-validator-bom")
1515
}
1616

1717
val ossrhUsername: String by project.ext

buildSrc/src/main/kotlin/convention.publication.gradle.kts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,34 @@ val javadocJar by tasks.registering(Jar::class) {
99

1010
fun getExtraString(name: String) = ext[name]?.toString()
1111

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+
1240
afterEvaluate {
1341
publishing {
1442

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
plugins {
2+
`java-platform`
3+
convention.publication
4+
}
5+
6+
configurations.api.configure {
7+
dependencyConstraints.addAllLater(
8+
bomService.coordinates
9+
.map { coordinates ->
10+
coordinates
11+
.distinct()
12+
.map(project.dependencies.constraints::create)
13+
},
14+
)
15+
}
16+
17+
publishing {
18+
publications {
19+
create<MavenPublication>("jsonSchemaValidatorBom") {
20+
from(components["javaPlatform"])
21+
}
22+
}
23+
}

settings.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ rootProject.name = "json-schema-validator-root"
55
include(":test-suites")
66
include(":benchmark")
77
include(":json-schema-validator")
8-
include(":json-schema-validator-objects")
8+
include(":json-schema-validator-objects")
9+
include(":json-schema-validator-bom")

0 commit comments

Comments
 (0)