How to declare multiple dependency with the same group

Hi, guys ,can gradle declare dependenices which has the same group like below style

compile (‘org.groupname’:[‘nameone’,‘nametow’,‘namethree’,…],‘versionnum’)

or difference version like this:


instead of duplicate declare group or version numbers

Using a bit of Groovy should do it:

dependencies {
  def fooBundle = [group:, version: '1.2.3']
  compile(['core', 'spi', 'impl'].collect { [module: it] << fooBundle })

Alternatively, you may define the fooBundle in a central location, or decide to use Maven-style BOM’s.

1 Like

If you simply want to define your groups and versions in a single place you can do

ext {
   groups = [foo: 'org.groupname']
   versions = [foo: '1.2.3']
dependencies {
    compile "${}:nameone:${}"
    compile "${}:nametwo:${}"
    compile "${}:namethree:${}"

As @ddimitrov mentioned, Gradle 4.6 added BOM import support which would also solve the problem

thanks for the good idea,that is a bit usage for me

Thanks for the soluation ,that looks like a good idea ,guy!