# Dependency management

**URL:** https://discuss.gradle.org/t/dependency-management/4573
**Category:** Old Forum Archive
**Created:** [November 20, 2012, 12:06pm UTC](https://discuss.gradle.org/t/dependency-management/4573 "2012-11-20T12:06:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![u1234](https://avatars.discourse-cdn.com/v4/letter/u/2acd7d/32.png) [@u1234](https://discuss.gradle.org/u/u1234)
#### Post date: [November 20, 2012, 12:06pm UTC](https://discuss.gradle.org/t/dependency-management/4573/1 "2012-11-20T12:06:00Z")

</div>

Maven offers dependencyManagment:

[http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html](http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html)

making it possible to set version used throughout a project in one pom file. What is the equivalent in gradle, I have looked at this:

[http://gradle.org/docs/current/userguide/dependency\_management.html](http://gradle.org/docs/current/userguide/dependency_management.html)

but I need to be able to setup dependencies without specifying versions (assuming they have been specified in eg. a common plugin/project).

---

<div class="post-metadata">

### Author: ![Detelin](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@Detelin](https://discuss.gradle.org/u/Detelin)
#### Post date: [November 20, 2012, 6:00pm UTC](https://discuss.gradle.org/t/dependency-management/4573/2 "2012-11-20T18:00:00Z")

</div>

AFAIK there is no dependency inheritance in Gradle. Gradle uses configuration injection instead, see [Cross project configuration](http://www.gradle.org/docs/current/userguide/userguide_single.html#sec:cross_project_configuration). You could define a list of dependencies in the root project and then re-use it when configuring each subproject, this way you will not have to specify a version more than once.

---

<div class="post-metadata">

### Author: ![mbjarland1](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@mbjarland1](https://discuss.gradle.org/u/mbjarland1)
#### Post date: [November 21, 2012, 4:02pm UTC](https://discuss.gradle.org/t/dependency-management/4573/3 "2012-11-21T16:02:00Z")

</div>

I’m assuming the question is in the context of a multi-project build?

Something that seems to be somewhat of a convention (the gradle source uses this in their build files) is to define some project extension properties on the root project, i.e. something like:

```gradle
ext {
  log4jVersion = "1.2.17"
  groovyVersion = "2.0.5"
}

```

you can then either apply these to all subprojects in the same file:

```gradle
//in the same build.gradle as the above ext definition
allprojects {
   apply plugin: 'groovy'
    dependencies {
     groovy
"org.codehaus.groovy:groovy:$groovyVersion"
    compile "log4j:log4j:$log4jVersion"
  }
}

```

or use them in a build.gradle for a specific sub project:

```gradle
//<root>/subProjectA/build.gradle
  dependencies {
     groovy
"org.codehaus.groovy:groovy:$groovyVersion"
    compile "log4j:log4j:$log4jVersion"
  }

```

This is assuming that your various subprojects do not have the exact same dependencies, but differing subsets of the dependencies but you would always like for a specific dependency (like log4j above) to be fixed to a specific, globally configured version.
