Add non-Java sources to existing Gradle project

Answered

We have multiple git repositories, and a Gradle project spanning two of them.  There is a third git repository "tools" which contains shell scripts and the like.  I would like to add "tools" to my IntelliJ Gradle Java project just so that the files show up in the project explorer and in "search everywhere" and so on, so that they can be edited.

Let's say the main repo is "product", a secondary repo with Java is "plugins", and then we have "tools".  There is "product/build.gradle" which defines the project structure -- some subfolders of "product" and some subfolders of "plugins" are included, and in IntelliJ I can see a top-level item "product" (everything under it is shown) plus multiple top-level items, one for each subfolder in "plugins" that is a Gradle project.

Now it would be wonderful if I could see another top-level item "tools" in the project view, so that those files are accessible, too.

0
3 comments

How (if) you are using the tools module by the Gradle?

0

It turns out there is a simple solution:

I have checked out the three repositories under a common root:

  • ~/git/main/product
  • ~/git/main/plugins
  • ~/git/main/tools

Now I open "~/git/main" in IntelliJ, navigate to "product/build.gradle", right click that, and import the Gradle project.

Et voilà.  Now I can navigate all files and folders from the Projects view (Cmd-1), and also there is a Gradle project that I can build.  Nifty.

I don't know why I've been using this for more than a year without having this simple idea.

1

Right. If you are not using the tools project in any of your Gradle projects logic you may open it just as a simple IDE module (of a Static Web type in your case with shell scripts).

0

Please sign in to leave a comment.