How to know whether project is part of mutliproject build

Hi All, I have two projects - project A and project B as part of a multi project build. project B has dependency on project A.

If the build is happening from the root project , I need to have compile project dependency i.e. compile project(":A") If the build is happening from the sub project B, I need to have normal dependency .i.e. compile “groupid:A”

To have this sort of dynamic nature of dependency , I need to first know whether the build is executing from root or from the sub project.

Can I use something like project.buildDir == currentDir to identify that I am building at sub project level ?

Thanks as usual for the brilliant support.

Which bigger problem are you trying to solve?

Well , when the build happens from the root , our repository is clean and project A has to be compiled first so that project B can refer it. Generally when developers do a build on project B alone ( at sub project level ) ,we have advised them to use --no-rebuild option so that Project A is not recompiled every time . ( It takes lot of time to build Project A )

We would like to see if this can be automated so that when build happens at sub project level , we can either set --no-rebuild to true or change the nature of dependency .

If project A has been built before, its tasks should be ‘up-to-date’ and it should take almost no time to build. If it still needs a long time to build, there is probably something wrong with the build, and it’s better to fix that, rather than suddenly consuming the project from a different location.

Ok. Will check again .

Thanks for the information .I could observe the comment “UP-TO-DATE” in the console and recompilation does not happen in normal scenario.

In this specific case , project A has a task related to process resources ( basically creating java source from wsdl ) , it generates the source code and compiles it. Thats the reason it was taking more time .