4

I am starting to migrate from ANT to Gradle and I have multiple projects which rely on one another. They are not all in the same path, meaning that they are not all under a single project but still they have dependencies with one another.

I read that in Gradle in order to define a dependency between two projects, they need to be under the same root project.

Can I avoid this? how can I give project compile(..) a path which is outside of the current path?

In other words, I don't want to start changing the path of the projects, for now.

Guy Avraham
  • 3,482
  • 3
  • 38
  • 50
Raz
  • 489
  • 3
  • 8
  • 17

2 Answers2

6

Also, i found this while searching for information on including projects/modules that are not in the same path:

https://looksok.wordpress.com/2014/07/12/compile-gradle-project-with-another-project-as-a-dependency/

It explains what Awanish Raj explained above, and more.

Raz
  • 489
  • 3
  • 8
  • 17
5

I hope you understand basics of grade file structure in the project.

Refer to my answer here for a solution to getting external library projects to compile into your main project.

Hope it helps! :)

Community
  • 1
  • 1
Awanish Raj
  • 1,939
  • 16
  • 17
  • it works! and a smaller question, i am using gradle eclipse plugin, and when i click "refresh all" in the gradle menu, the projects in the build path are deleted, and only after i run the 'eclipse' task then the projects in the build path are back. this is how its supposed to be? – Raz Jul 26 '15 at 09:02
  • 1
    Yes Avra, this how its supposed to be. `Build` files are generated at every run entirely from your code. Your code is safe. In fact, you should ignore `build` directory while implementing any version control also! :) – Awanish Raj Jul 27 '15 at 11:29
  • can i make the "eclipse" task run automaticaly when i click "refresh-all" ? – Raz Aug 03 '15 at 12:39
  • @AwanishRaj - dont want to downvote this since this the answer. please add information about the answer here. A few lines should be fine. Or you can mark this question as duplicate if it is. thanks – Parv Sharma Nov 22 '20 at 13:54