Subproject in settings.gradle does not build


(Zsolt Kúti) #1

Hello,

One of the subprojects (A) in my project does not build when the project is built. This subproject has dependendencies on others, but no other subprojects depend on it (as soon as I change this A builds). This subproject A is in the settings.gradle and builds fine in itself.

How can I achieve building this subproject together with the root project?

Thanks! Zsolt


(Zsolt Kúti) #2

FYI. A well placed rootProject.dependsOn(":A") solved the problem.


(Peter Niederwieser) #3

‘Project.dependsOn’ is deprecated. It’s important to understand that Gradle always executes tasks, not projects. Hence execution dependencies are also between tasks. If subproject ‘B’ does not “execute”, then it just means that none of its tasks are required for this particular build invocation. For example, maybe you typed ‘gradle build’ and subproject ‘B’ does not have a ‘build’ task.


(Zsolt Kúti) #4

Thanks for the warning and explanation Peter!

This subproject part of the project as an autonome service. What to do then? As a quick hack I made one of the subprojects to depend on A, but there must be a more elegant solution.


(Peter Niederwieser) #5

If the project has no ‘build’ task, then you should add one. Then running ‘gradle build’ from the top will also run that task (and its task dependencies).