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:
compile(‘org.groupname’,[‘nameone:version1’,‘nametwo:version2’,…])
instead of duplicate declare group or version numbers
ddimitrov
(Dimitar Dimitrov)
2
Using a bit of Groovy should do it:
dependencies {
def fooBundle = [group: com.acme.foo, 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
Lance
(uklance)
3
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 "${groups.foo}:nameone:${versions.foo}"
compile "${groups.foo}:nametwo:${versions.foo}"
compile "${groups.foo}:namethree:${versions.foo}"
}
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!