IntelliJ trouble when including a local copy of a library as a dependency


(Kirill Romanov) #1

My game uses a library that I need to make adjustments to. I forked the library on github and cloned my fork, it’s a multiproject gradle build. I’m trying to change my game’s build scripts to depend on the local copy of the library instead of the maven version.

The library itself is actually a subproject of its root project, as it also includes a demo app. Furthermore, I can’t include the library subproject directly, because its build.gradle relies on “ext” properties set by its parent build.gradle. In other words, it needs to process the root build.gradle, or else it fails to configure.

This is how I set it up:

settings.gradle for my game

include "mysubproject1", "mysubproject2"
include ":foolib" // root project
project(":foolib").projectDir = file("C:/projects/foolib")
include ":foolib:foolib" // note: the actual library is a subproject!

in build.gradle for my game

compile project(":foolib:foolib")

With this, gradlew run in command prompt succeeds, so it seems to work.

However, when performing the same run task from IntelliJ, gradle fails to configure because the “ext” properties are not set - just like before! Furthermore, IntelliJ’s Project tab shows a confusing and redundant directory structure, suggesting IntelliJ is treating the subproject as a root project alongside the actual root project. I guess because I’ve included both of them separately in settings.gradle.

I could not find another way to write settings.gradle that fixed the IntelliJ problem. Any ideas?