Skip to content

enhancement: add BOM module #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ allprojects {
}

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

val ossrhUsername: String by project.ext
Expand Down
28 changes: 28 additions & 0 deletions buildSrc/src/main/kotlin/convention.publication.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,34 @@ val javadocJar by tasks.registering(Jar::class) {

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

/**
* Create a service for collecting the coordinates of all artifacts that should be included in the bom.
*/
abstract class BomService : BuildService<BuildServiceParameters.None> {
/** Coordinates that will be included in the BOM. */
abstract val coordinates: SetProperty<String>
}

val bomService: BomService =
gradle.sharedServices.registerIfAbsent("bomService", BomService::class).get()

extensions.add("bomService", bomService)

/** Controls whether the current subproject will be included in the kotest-bom. */
val includeInBom: Property<Boolean> =
objects.property<Boolean>().convention(project.name != "json-schema-validator-bom")

extensions.add<Property<Boolean>>("includeInBom", includeInBom)

bomService.coordinates
.addAll(
provider {
project.run { "$group:$name:$version" }
}.zip(includeInBom) { coordinates, include ->
if (include) listOf(coordinates) else emptyList()
},
)

afterEvaluate {
publishing {

Expand Down
23 changes: 23 additions & 0 deletions json-schema-validator-bom/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
`java-platform`
convention.publication
}

configurations.api.configure {
dependencyConstraints.addAllLater(
bomService.coordinates
.map { coordinates ->
coordinates
.distinct()
.map(project.dependencies.constraints::create)
},
)
}

publishing {
publications {
create<MavenPublication>("jsonSchemaValidatorBom") {
from(components["javaPlatform"])
}
}
}
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ rootProject.name = "json-schema-validator-root"
include(":test-suites")
include(":benchmark")
include(":json-schema-validator")
include(":json-schema-validator-objects")
include(":json-schema-validator-objects")
include(":json-schema-validator-bom")
Loading