Eclipse project config when using buildSrc

What’s the right way to import a gradle project that contains a buildSrc subproject into eclipse? (I’m making the assumption that buildSrc is a real gradle sub project even though it’s a convention based thing.

Both my top level project and buildSrc have build.gradle scripts:

├── build.gradle
├── buildSrc
│   ├── build.gradle
│   └── src
│  
   └── main
│  
       ├── groovy
│  
       │   └── com
│  
       │  
   └── ..... lots of groovy
│  
       ├── java
│  
       │   └── com
│  
       │  
   └── .... lots of java
│  
       └── resources
├── src
│   ├── main
│   │   ├── groovy
│   │   ├── java
│   └── test
│  
   └── java

If I import just the top level project, even with “automatically include sub-projects” checked, it’s missing the buildSrc source directories.

What’s needed in the top level build.gradle to make the eclipse target include the buildSrc source directories in the eclipse project?

If I add them manually to the project they get deleted when I refresh the config from gradle.

if I import buildSrc as a separate gradle project, it’s still not working right as I can’t stop on breakpoints in the buildSrc code after I attach to a remote gradle jvm running my build, so I’m assuming I just don’t have the project setup correctly.

Here’s the answer in case anyone else runs into this. It’s completely obvious in hindsight, but these things are often elusive on the learning curve.

Just add the buildSrc sources to the sourceSets:

sourceSets {
    main {
        java {
            srcDir 'src/main/java'
            srcDir 'src/main/groovy'
            srcDir 'buildSrc/src/main/java'
            srcDir 'buildSrc/src/main/groovy'
        }
        resources {
            srcDir 'src/resources'
            srcDir 'buildSrc/src/resources'
        }
    }
}

The default only includes the first two entries, anything after that must be stated explicitly.

I guess my problem was that I thought buildSrc was a build-in gradle thing where if it existed it was automatically used so I expected that it’s source directories would be implied as well, rather than requiring the explicit addition.