[SOLVED] How to add subprojects to classpath when I run the main project?

Hello everyone! I need to create a project with structure like this:

MainProjectDir
├───... // MainProject build dirs and other stuff
│
├───examples // Directory with example projects 
│   ├───case1 // example #1
│   │   └───src
│   │       └───main
│   │           ├───java
│   │           └───resources
│   │
│   ├───case2 // example #2
│   │   └───src
│   │       └───main
│   │           ├───java
│   │           └───resources
│   │
│   └─── ... // etc
│
└───src // MainProject src directory
    └───main
        ├───java
        └───resources

Example projects depend on MainProject via compile keyword:

dependencies {
    compile project(':MainProject')
}

But I need to run the main project in such a way that the subprojects are added to classpath. I know that i can do this with addind dependency in MainProject’s build.gradle but it will lead to circular dependencies. Ho can i add subprojects compiled classes to classpath when run MainProject?

I really hope for your help, because I have been working on this problem for a very long time and I am very tired. Thanks in advance, comrades, and sorry for my english.

Come on guys! I know you know how to solve this.

I just needed to use runtimeOnly dependency configuration:

dependencies {
    runtimeOnly project(':case1')
    runtimeOnly project(':case2')
}

PS: The worst support I’ve ever seen