# Issue in Project dependencies in a multi module project

**URL:** <https://discuss.gradle.org/t/issue-in-project-dependencies-in-a-multi-module-project/7426>\
**Category:** Old Forum Archive\
**Created:** [July 26, 2013, 12:17pm UTC](https://discuss.gradle.org/t/issue-in-project-dependencies-in-a-multi-module-project/7426 "2013-07-26T12:17:00Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Smurf](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@Smurf](https://discuss.gradle.org/u/Smurf)\
**Post date:** [July 26, 2013, 12:17pm UTC](https://discuss.gradle.org/t/issue-in-project-dependencies-in-a-multi-module-project/7426/1 "2013-07-26T12:17:00Z")

</div>

Hi

I have two projects[a,b] and i want them to build project [A] first before project [B].

But, if i give as

```gradle
project(':B'){
 dependsOn(':A:compile')
}

```

i am getting the below error: The Project.dependsOn(String path) method has been deprecated and is scheduled to be removed in Gradle 2.0. Can you please let me know, how to do it.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [July 26, 2013, 12:39pm UTC](https://discuss.gradle.org/t/issue-in-project-dependencies-in-a-multi-module-project/7426/2 "2013-07-26T12:39:00Z")

</div>

You likely want a _project dependency_ from B on A. For details, see the multi-project builds chapter in the [Gradle User Guide](http://gradle.org/docs/current/userguide/userguide_single.html), and the many samples in the full Gradle distribution.

---

<div class="post-metadata">

**Author:** ![Smurf](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@Smurf](https://discuss.gradle.org/u/Smurf)\
**Post date:** [July 26, 2013, 2:22pm UTC](https://discuss.gradle.org/t/issue-in-project-dependencies-in-a-multi-module-project/7426/3 "2013-07-26T14:22:00Z")

</div>

Hi Peter

In that, they have mentioned project dependencies on a task.

I want project B to be compiled and built only after project A.

In settings.xml, even though i add as

include ‘:A’,’:B’

It is building [B] first. Can you help on that

Regards Smurf

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [July 26, 2013, 2:28pm UTC](https://discuss.gradle.org/t/issue-in-project-dependencies-in-a-multi-module-project/7426/4 "2013-07-26T14:28:00Z")

</div>

> In that, they have mentioned project dependencies on a task.

Not sure what you mean by that.

> I want project B to be compiled and built only after project A.

Why do you want that? In Gradle, projects aren’t built one after another. Instead, ordering happens on the _task_ level. And to get the right task ordering, you’ll have to add a _project dependency_.

> In settings.xml, even though i add as

I assume you mean ‘settings.gradle’.

> It is building [B] first.

The order of 'include’s in ‘settings.gradle’ is irrelevant.

---

<div class="post-metadata">

**Author:** ![Smurf](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@Smurf](https://discuss.gradle.org/u/Smurf)\
**Post date:** [July 26, 2013, 2:50pm UTC](https://discuss.gradle.org/t/issue-in-project-dependencies-in-a-multi-module-project/7426/5 "2013-07-26T14:50:00Z")

</div>

Consider i have two projects A and B In the dependencies section of B, i have added as below:

compile “com.test:A:1.0.0”

So, the project B is dependent on project A.

In settings.gradle, i have included as: include ‘:A’,’:B’

When i do a gradle build from the root , it is building project B and throws the error that project A does not exist.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [July 26, 2013, 2:55pm UTC](https://discuss.gradle.org/t/issue-in-project-dependencies-in-a-multi-module-project/7426/6 "2013-07-26T14:55:00Z")

</div>

> In the dependencies section of B, i have added as below: compile “com.test:A:1.0.0”

That’s not a project dependency. Please read the docs. It’s as simple as searching the [Gradle User Guide](http://gradle.org/docs/current/userguide/userguide_single.html) for “project dependency”.

---

<div class="post-metadata">

**Author:** ![Smurf](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@Smurf](https://discuss.gradle.org/u/Smurf)\
**Post date:** [July 26, 2013, 3:10pm UTC](https://discuss.gradle.org/t/issue-in-project-dependencies-in-a-multi-module-project/7426/7 "2013-07-26T15:10:00Z")

</div>

I read the turorial that you have sent, and i implemented as below and getting the error ☹

As you said earlier, ‘The order of includes in settings.gradle is irrelevant.’ . I wanted to order the list of projects. I read the turorial that you have sent, i have tried the below:

project(’:B) {

dependencies {

compile project(’:A’) }

But, i am getting the below error: tting the below error:

The Project.dependsOn(String path) method has been deprecated and is scheduled to be removed in Gradle 2.0.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [July 26, 2013, 3:14pm UTC](https://discuss.gradle.org/t/issue-in-project-dependencies-in-a-multi-module-project/7426/8 "2013-07-26T15:14:00Z")

</div>

This code:

```gradle
project(':B) {
     dependencies {
         compile project(':A')
 }

```

is correct (except that it’s missing a closing quote and a closing brace) and will NOT result in the warning:

```gradle
The Project.dependsOn(String path) method has been deprecated and is scheduled to be removed in Gradle 2.0.

```

The offending code must look similar to the code that you originally posted:

```gradle
project(':B'){
    dependsOn(':A:compile')
}

```

This code WILL result in the warning shown above and should be removed.

---

<div class="post-metadata">

**Author:** ![Smurf](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@Smurf](https://discuss.gradle.org/u/Smurf)\
**Post date:** [July 26, 2013, 3:29pm UTC](https://discuss.gradle.org/t/issue-in-project-dependencies-in-a-multi-module-project/7426/9 "2013-07-26T15:29:00Z")

</div>

Sorry, i just typed those commands in forum .So i missed the closing quote. Still getting the same.

If i am giving as below ,

```gradle
project(':B'){
    dependsOn(':A:compile')
}

```

am getting the below error:

> Project with path ‘🅰compile’ could not be found in project ‘:B’.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [July 26, 2013, 3:57pm UTC](https://discuss.gradle.org/t/issue-in-project-dependencies-in-a-multi-module-project/7426/10 "2013-07-26T15:57:00Z")

</div>

One last time, you need to get rid of that code. It’s wrong _and_ deprecated. Don’t you see the difference between:

GOOD

```gradle
project(':B') {
     dependencies {
         compile project(':A')
     }
}

```

BAD

```gradle
project(':B') {
    dependsOn(':A:compile')
}

```

---

<div class="post-metadata">

**Author:** ![Smurf](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@Smurf](https://discuss.gradle.org/u/Smurf)\
**Post date:** [July 26, 2013, 4:08pm UTC](https://discuss.gradle.org/t/issue-in-project-dependencies-in-a-multi-module-project/7426/11 "2013-07-26T16:08:00Z")

</div>

OK. I think you did not understand. I tried the first way project(’:B’) {

dependencies {

compile project(’:A’)

} } It did not work.

Then i tried, the bad approach which gives the err. I will try and let you know, what was wrong in my project.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [July 26, 2013, 4:10pm UTC](https://discuss.gradle.org/t/issue-in-project-dependencies-in-a-multi-module-project/7426/12 "2013-07-26T16:10:00Z")

</div>

Define “did not work”. It won’t run the projects in a fixed order. That’s not how Gradle works, and it shouldn’t be necessary either.
