Example of how to use a BOM in Gradle to share dependency versions across projects.
This example contains the following projects:
- platform - The BOM project that defines the shared dependencies.
- project-a - A project that uses the platform BOM.
- project-b - A project that uses the platform BOM.
Run the following command to build the example and create a Gradle Build Scan:
./gradlew clean build --scan
If successful, you will see that your build published a build scan:
BUILD SUCCESSFUL in 1s
11 actionable tasks: 10 executed, 1 up-to-date
Publishing build scan...
https://gradle.com/s/o4xloi6jkmnck
This build's build scan can be found at: https://gradle.com/s/o4xloi6jkmnck
Use the Gradle Build Scan created by your build to check out the dependency resolution.
-
Navigate to the build scan URL in a web browser.
-
Select the
Dependencies
tab in the right-hand menu. -
Notice in the image below that the
platform
dependencies have been included as constraints and theslf4j-api
dependency's selection reason isConstraint
.
For bugs, questions, and discussions please use the Github Issues.
MIT License
Copyright (c) 2020 Greg Whitaker
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.