Skip to content

Commit

Permalink
Share bom inclusion closure to reduce code duplication (#2307)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scottmitch authored Aug 4, 2022
1 parent 5cfe9c4 commit ccf01ca
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
18 changes: 18 additions & 0 deletions gradle/bomUtils.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright © 2022 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

ext.bomInclusionClosure = {it -> !it.name.endsWith("-bom") && !it.name.endsWith("-dependencies") &&
!it.name.contains("examples") && !it.name.equals("grpc") && !it.name.equals("http")}
10 changes: 3 additions & 7 deletions servicetalk-bom/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2018-2019 Apple Inc. and the ServiceTalk project authors
* Copyright © 2018-2019, 2022 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,15 +16,11 @@

apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-core"
apply plugin: "java-platform"
apply from: "../gradle/bomUtils.gradle"

description="ServiceTalk BOM that includes all modules"

// IMPORTANT: Ensure that the module list is consistent with `servicetalk-dependencies`
rootProject.subprojects.findAll { !it.name.endsWith("-bom") &&
!it.name.endsWith("-dependencies") &&
!it.name.contains("examples") &&
!it.name.equals("grpc") &&
!it.name.equals("http") }.each {
rootProject.subprojects.findAll { it -> bomInclusionClosure(it) }.each {
dependencies.constraints.add("api", it)
}

Expand Down
10 changes: 3 additions & 7 deletions servicetalk-dependencies/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2018-2019 Apple Inc. and the ServiceTalk project authors
* Copyright © 2018-2019, 2022 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,21 +16,17 @@

apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-core"
apply plugin: "java-platform"
apply from: "../gradle/bomUtils.gradle"

description = "ServiceTalk BOM that includes all modules and direct dependencies"

javaPlatform {
allowDependencies()
}

// IMPORTANT: Ensure that the module list is consistent with `servicetalk-bom`
// Include modules directly rather than by defining servicetalk bom as
// a platform to work around [MNG-6772](https://issues.apache.org/jira/browse/MNG-6772).
rootProject.subprojects.findAll { !it.name.endsWith("-bom") &&
!it.name.endsWith("-dependencies") &&
!it.name.contains("examples") &&
!it.name.equals("grpc") &&
!it.name.equals("http") }.each {
rootProject.subprojects.findAll { it -> bomInclusionClosure(it) }.each {
dependencies.constraints.add("api", it)
}

Expand Down

0 comments on commit ccf01ca

Please sign in to comment.