# Grouping dependencies

**URL:** <https://discuss.gradle.org/t/grouping-dependencies/5822>\
**Category:** Old Forum Archive\
**Created:** [August 10, 2014, 2:09pm UTC](https://discuss.gradle.org/t/grouping-dependencies/5822 "2014-08-10T14:09:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![phil\_swenson](https://avatars.discourse-cdn.com/v4/letter/p/f17d59/32.png) [@phil\_swenson](https://discuss.gradle.org/u/phil_swenson)\
**Post date:** [August 10, 2014, 2:09pm UTC](https://discuss.gradle.org/t/grouping-dependencies/5822/1 "2014-08-10T14:09:00Z")

</div>

Does gradle have a way to group a set of dependencies?

For example if I want to declare a dependency on Jetty, I don’t want to have to declare a list of all the Jetty dependencies (list of ~ 20 jars). I would really like to have a way to list all the dependencies associated with jetty somewhere and in gradle simply declare the jetty dependency…

thanks phil

---

<div class="post-metadata">

**Author:** ![ghhale](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/ghhale/32/26_2.png) [@ghhale](https://discuss.gradle.org/u/ghhale)\
**Post date:** [August 10, 2014, 2:26pm UTC](https://discuss.gradle.org/t/grouping-dependencies/5822/2 "2014-08-10T14:26:00Z")

</div>

You can define a list in a common script and pass it to a dependency declaration anywhere you need it:

```gradle
def myLibs = ['org.myorg:api:1.0', 'org.myorg:util:2.1']
...
dependencies {
  compile myLibs
}

```

---

<div class="post-metadata">

**Author:** ![phil\_swenson](https://avatars.discourse-cdn.com/v4/letter/p/f17d59/32.png) [@phil\_swenson](https://discuss.gradle.org/u/phil_swenson)\
**Post date:** [August 10, 2014, 3:58pm UTC](https://discuss.gradle.org/t/grouping-dependencies/5822/3 "2014-08-10T15:58:00Z")

</div>

this helps…

but if you have many projects that want to share this information, it would be useful to publish the “library” to artifactory.

That way an project using a repository could simply declare a dependency on “jetty” and get all the associated dependencies…

does any concept like this exist for gradle?

thanks phil

---

<div class="post-metadata">

**Author:** ![ghhale](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/ghhale/32/26_2.png) [@ghhale](https://discuss.gradle.org/u/ghhale)\
**Post date:** [August 10, 2014, 4:16pm UTC](https://discuss.gradle.org/t/grouping-dependencies/5822/4 "2014-08-10T16:16:00Z")

</div>

Well, really what you are talking about is common configuration that you want to share between builds and plugins are the mechanism for doing this. &nbsp;Two ways you can approach it:

- Add the configuration to a script plugin, publish it to your repository (e.g. artifactory) and then apply it from its http url.
- Add the configuration to a binary plugin, publish it to your repository and then apply the plugin as a buildscript dependency.

In either case, your plugin can either automatically add the jetty dependencies to your build or just make them available via an extension of some sort so that a project can easily add the jetty libraries with one line. &nbsp;Depends on what you need/want to do.  
  
Script plugins are more simplistic, but you’ll have to publish them manually and they don’t get cached. &nbsp;Binary plugins are slightly more involved, but they can be published like any other artifact and they’ll get cached like any other artifact.
