Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Gradle's DependencySet in depencencies block or other way to use multiple modules from one group

Tags:

gradle

Gradle has an interface called DependencySet that Spring's dependency-management-plugin can use in a dependencies block in a dependencyManagement block like below. (Code from here for reference.)

dependencyManagement {
     dependencies {
          dependencySet(group:'org.slf4j', version: '1.7.7') {
               entry 'slf4j-api'
               entry 'slf4j-simple'
          }
     }
}

This is a very pretty to group dependencies that are in the same group. The more dependencies in the group the prettier it gets. Projects tend to have a lot of dependencies from the same group, especially if you are using Spring. Is there any way to use a similar notation in the "real" dependencies block?

like image 874
Captain Man Avatar asked Mar 02 '17 16:03

Captain Man


1 Answers

I am afraid there isn't a way how to use dependencySet outside of the dependencyManagement section added by the Spring dependency-management-plugin plugin.

You can take a look at the following classes to see how the dependencies are being read from the script:

  • DefaultProject - method dependencies()
  • DefaultDependencyHandler

The interface for dependencySet is used differently in Gradle. For example it is returned when you want to know all dependencies from a configuration.

like image 194
MartinTeeVarga Avatar answered Sep 28 '22 01:09

MartinTeeVarga