'How to configure Eclipse with Gradle in multi project?

I'm using Eclipse Mars, Buildship plugin, JDK 1.8 and Gradle 2.9 on OS X

I need below structure in Eclipse. How to configure and create?

my-examples/
    settings.gradle
    01_example/
        build.gradle
        src/main/java
        src/main/resources
        src/test/java
        src/test/resources
    02_example/
        build.gradle
        src/main/java
        src/main/resources
        src/test/java
        src/test/resources
    03_example/
        build.gradle
        src/main/java
        src/main/resources
        src/test/java
        src/test/resources

The root directory my-examples is just wraps sub directories(01_example, 02_example, 03_example).


Here is build.gradle in root directory I tried to configure:

subprojects {
   apply plugin: 'java'
   sourceCompatibility = 1.8
   targetCompatibility = 1.8
   repositories {
       jcenter()
   }
   task initSourceFolders {
       sourceSets*.java.srcDirs*.each { it.mkdirs() }
       sourceSets*.resources.srcDirs*.each { it.mkdirs() }
   }
}

Edited

First, I created a directory and created build.gradle and settings.gradle with include exam1, include exam2, and include exam3. Now I imported the project from Gradle Project. The sub directories has been created that I needed.

But problem is that I can't create another sub directory in Eclipse and it's same in shell mkdir exam4 and gradle build. Always It has been created normal folder.

Project workspace in Eclipse



Solution 1:[1]

You can try to install Gradle plugin for eclipse from here:

"https://github.com/spring-projects/eclipse-integration-gradle/blob/master/README.md"

Installation steps are given here: "https://github.com/spring-projects/eclipse-integration-gradle/blob/master/README.md#installation-instructions".

You can view the following post for further information:

"Launching Gradle builds from Eclipse".

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community