Issue in Project dependencies in a multi module project

Hi

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

But, if i give as

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.

You likely want a project dependency from B on A. For details, see the multi-project builds chapter in the Gradle User Guide, and the many samples in the full Gradle distribution.

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

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.

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.

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 for “project dependency”.

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

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.

This code:

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:

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:

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

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

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

If i am giving as below ,

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

am getting the below error:

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

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

GOOD

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

BAD

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

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.

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.