lyomi
lyomi

Reputation: 4370

IntelliJ IDEA with multiple gradle subprojects

I'm working on multiple Gradle projects with internal and external dependencies, and so far I am happy that thanks to Gradle's dependency management I can modify a library project without affecting every application that uses the library.

When I need to modify a library project and test it using an application project that uses it, I need to do the following,

So it became quite combersome now. Can I configure IntelliJ IDEA so that

Finagle subprojects

Thanks.

Upvotes: 22

Views: 41404

Answers (2)

RubenLaguna
RubenLaguna

Reputation: 24676

Currently in IntelliJ IDEA 2019.2 you can add the gradle subprojects like so

  1. Open Gradle Tool Window via View > Tool Windows > Gradle menu
  2. Click on "Link Gradle Project" button (the plus sign)Link Gradle Project button
  3. Select the build.gradle file corresponding to the subproject
  4. Go to File > Project Structure > Modules > NameOfSubproject
  5. Navigate to main/java and click on Mark as: Sources enter image description here
  6. Mark the main/resources as Resources
  7. Restart IntelliJ IDEA

The sources of the subproject will be recognized by IntelliJ and you can use Navigate Class action for the classes in the subproject

Upvotes: 16

Peter Niederwieser
Peter Niederwieser

Reputation: 123900

If you want to open all projects in a single IDEA window, you'll have to aggregate them into a multi-project build, at least until IDEA 13 hits the market. Before IDEA 13, it's better to use Gradle's IDEA integration. Once you have a multi-project build, all you need to do is to add allprojects { apply plugin: "idea" } to the root build script, run gradle (cleanIdea) idea, then open the generated IDEA project.

Upvotes: 23

Related Questions