How to create a company specific parent dependency file which can be used across company specific gradle initiated projects
Sample libraries which I want to share across projects
dependencies {
// logging
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
implementation group: 'org.slf4j', name: 'log4j-over-slf4j', version: '1.7.30'
// elasticsearch
implementation group: 'org.elasticsearch', name: 'elasticsearch', version: '7.13.2'
implementation group: 'org.elasticsearch.client', name: 'elasticsearch-rest-high-level-client', version: '7.13.2'
}
It depends on what is the goal of the parent POM? If it's only for the consolidation dependency versions, you can use a version catalog. A version catalog is a list of dependencies, represented as dependency coordinates, that a user can pick from when declaring dependencies in a build script.
settings.gradle
enableFeaturePreview('VERSION_CATALOGS')
dependencyResolutionManagement {
versionCatalogs {
libs {
// logging
alias('slf4j-api').to('org.slf4j:slf4j-api:1.7.30')
alias('log4j-over-slf4j').to('org.slf4j:log4j-over-slf4j:1.7.30')
// elasticsearch
alias('elasticsearch').to('org.elasticsearch:elasticsearch:7.13.2')
alias('elasticsearch-client').to('org.elasticsearch.client:elasticsearch-rest-high-level-client:7.13.2')
alias('elasticsearch-rest').to('org.elasticsearch.client:elasticsearch-rest-client:7.13.2')
}
}
}
build.gradle
dependencies {
// logging
implementation libs.slf4j.api
implementation libs.log4j.over.slf4j
// elasticsearch
implementation libs.elasticsearch
implementation libs.elasticsearch.client
implementation libs.elasticsearch.rest
}