1

What is the easiest way of setting up a gradle configuration so that I can run tests for only one or two submodules in a multimodule project?

The reason I don't need to test all of them is because they reside in their own repositories and get tested when those are changed. It really increases the turnaround-time to have TeamCity run a shitload of tests that I know will pass.

My initial thought was to set up a task in the top-level build.gradle that has dummy implementations in the modules that don't need to run the tests and performs connectedCheck for the android submodule and runs the tests for the java ones, but I havn't gotten that to work yet. I looked at the gradle documentation for multi-project builds (http://www.gradle.org/docs/current/userguide/multi_project_builds.html) but couldn't figure out how to call the clean and build commands from inside a Closure.

Help? :)

Coinhunter
  • 83
  • 1
  • 9
  • If they have their own repositories, why are they subprojects? – Peter Niederwieser Sep 08 '14 at 15:35
  • Because the Android application that is the core in this project have them as dependencies. – Coinhunter Sep 08 '14 at 15:38
  • 1
    You should probably just depend on the final artifact then, either by including it in a `/libs` directory of as a dependency from a repository. – Mark Vieira Sep 08 '14 at 17:23
  • Are you using Git submodules (or similar)? Please don't assume we know your project setup, but explain it in detail. – Peter Niederwieser Sep 08 '14 at 17:46
  • @PeterNiederweiser: I should perhaps have been more clear - yes, some of the modules are also git submodules. Why? – Coinhunter Sep 09 '14 at 14:31
  • @MarkVieira: Hmm, depend on the final artifact? Can you elaborate? – Coinhunter Sep 09 '14 at 14:32
  • Like Peter said, the description of your project is a bit vague. I can only assume that these subprojects produce some kind of artifact (jar for example). Rather than pull those projects in your parent project (since they apparently exist elsewhere in their own repo) why not just bring in the final artifact as a dependency. Either a) by copying it into a `/libs` folder, or b) adding it as a dependency. From what I understand you have separate builds that run the unit tests for these submodules. Do these build not also produce an artifact? – Mark Vieira Sep 09 '14 at 16:58
  • @MarkVieira: They do not currently produce artifacts that we can easily access. The idea was to not have to resort to using artifact distribution hubs like maven when gradle probably has built in support for this somewhere, somehow. So yes - it would work to do it like that. The question however is what the easiest way to do it using gradle is? :/ The submodules that are needed to build the android app are listed as dependencies in build.gradle, but when that builds it also runs the tests for those modules, which is what I want to avoid for some of them. – Coinhunter Sep 10 '14 at 15:30
  • This worked for me https://stackoverflow.com/a/37762794/710099 – Federico Piazza May 31 '19 at 01:38

0 Answers0