Adding an exploded version of a dependency

Consider the following project structure:

| – entrypoint
| – core

entrypoint, as you can already surmise, contains the main()method and includes core as a dependency

dependencies {
    compile project(":core")

What I want to do now is that, during development, when I call bootRun Gradle doesn’t include core from the .jar that it builds but the actual build folders (e.g. build/classes and build/resources.

I got it working by explicitly changing the dependency to

dependencies {
    // compile project(":core")

    compile files("${rootDir}/core/build/classes/java/main")
    compile files("${rootDir}/core/build/resources/main")

but obviously that’s not the best approach because if there’s any generated code or multiple sourcesets/resource dirs they all need to be added separately.

Is there any way to achieve this “automagically” a’la something like this ideally:

dependencies {
    compile project(":core") {
        useBuildDir = true

Have you found another solution to realize your idea? I am asking as I want to do exactly the same in our build and I would like to avoid listing the dependencies directly to the build folders.

What I have found is the “variants” feature from Gradle:

In the example, the secondary variants for “runtimeElements” seem to be exactly what we would like on the classpath. But I currently don’t know how this would be used as I don’t yet understand how this variation selection works.

It might work if you set the Gradle property to true.