[GRADLE-2680] Tooling API: Expose information about custom source sets Created: 12/Feb/13  Updated: 10/Feb/17  Resolved: 10/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: 1.4
Fix Version/s: None

Type: Bug
Reporter: Denis Zhdanov Assignee: Unassigned
Resolution: Won't Fix Votes: 11


Consider a simple project below:

apply plugin: 'java'

repositories {

dependencies {
  compile 'org.codehaus.groovy:groovy-all:2.1.0'
  compile 'org.scala-lang:scala-library:2.10.0'

sourceSets {
  integTest {}

configurations {
  integTestCompile.extendsFrom testCompile
  integTestRuntime.extendsFrom testRuntime

task integTest(type: Test) {
  testClassesDir = sourceSets.integTest.output.classesDir
  classpath = sourceSets.integTest.runtimeClasspath

It defines a custom source set, so, it's expected that the tooling api provides information about that. Unfortunately, it does not:

package org.jetbrains.plugins.gradle;

import org.gradle.tooling.*;
import org.gradle.tooling.internal.consumer.DefaultGradleConnector;
import org.gradle.tooling.model.idea.*;

import java.io.File;
import java.util.Date;
import java.util.concurrent.TimeUnit;

 * @author Denis Zhdanov
 * @since 12/8/11 5:07 PM
public class GradleStartClass {

  private static final String GRADLE_TO_USE       = "/home/denis/dev/gradle/gradle-1.4";
  private static final String GRADLE_PROJECT_PATH = "/home/denis/Downloads/gradle-content-root";

  public static void main(String[] args) throws InterruptedException {
    System.out.println("GRADLE_USER_HOME=" + System.getenv("GRADLE_USER_HOME"));
//    showDependencies(false);

  private static void showContentRoots() {
    IdeaProject project = getProject(false);
    for (IdeaModule module : project.getModules()) {
      System.out.printf("    -----------------> Module %s <----------------%n", module.getName());
      for (IdeaContentRoot root : module.getContentRoots()) {
        System.out.printf("    content root '%s'%n", root.getRootDirectory().getAbsolutePath());
        for (IdeaSourceDirectory sourceDirectory : root.getSourceDirectories()) {
          System.out.printf("        source dir: '%s'%n", sourceDirectory.getDirectory().getAbsolutePath());


  private static void showDependencies(boolean useWrapper) {
    IdeaProject project = getProject(useWrapper);
    System.out.println("-----------------> Listing modules <----------------");
    for (IdeaModule module : project.getModules()) {
      System.out.printf("    -----------------> Module %s <----------------%n", module.getName());
      for (IdeaDependency dependency : module.getDependencies()) {
        System.out.printf("Dependency: %s, scope: %s%n", dependency, dependency.getScope());
    System.out.println("-----------------> Finishing <----------------");

  private static IdeaProject getProject(boolean useWrapper) {
    GradleConnector connector = GradleConnector.newConnector();
    if (!useWrapper) {
      connector.useInstallation(new File(GRADLE_TO_USE));
    ((DefaultGradleConnector)connector).daemonMaxIdleTime(10000, TimeUnit.MILLISECONDS);
    connector.forProjectDirectory(new File(GRADLE_PROJECT_PATH));
    ProjectConnection connection = connector.connect();
    ModelBuilder<? extends IdeaProject> modelBuilder = connection.model(IdeaProject.class);
    System.out.println(new Date() + ": Starting project resolve");
    IdeaProject result = modelBuilder.get();
    System.out.println(new Date() + ": Project resolve is complete");
    return result;


-----------------> Module gradle-content-root <----------------
    content root '/home/denis/Downloads/gradle-content-root'
        source dir: '/home/denis/Downloads/gradle-content-root/src/main/resources'
        source dir: '/home/denis/Downloads/gradle-content-root/src/main/java'

Comment by Adam Murdoch [ 16/Feb/13 ]

Hi Dennis, this is definitely something we plan to do. One open question is how we decide whether to map a custom source set as a 'source folder' or a 'test source folder' in the IDEA project. Currently, we're doing some improvements to source sets and we should be able to infer this once we've made some progress in this direction.

Comment by Denis Zhdanov [ 18/Feb/13 ]

Hi Adam,

Ideally, it should be decided at runtime - if a source set has direct or indirect parent which is a 'source', then the custom set should be exposed as a 'source root' as well; when there is no parent over than 'test', custom set is a 'test' as well.

Comment by Sascha Kiedrowski [ 22/Oct/13 ]

Hi gradle team,

any news on this issue?


Comment by Vladislav Soroka [ 22/Oct/13 ]

It's blocking this IntelliJ Gradle feature: http://youtrack.jetbrains.com/issue/IDEA-115169

Comment by Vladislav Soroka [ 25/Nov/13 ]

it's not a blocker for http://youtrack.jetbrains.com/issue/IDEA-115169 anymore.
required information was retrieved using dynamic plugin applying but it would be nice to have such support in a regular tooling API.

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 10/Feb/17 ]

Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved.

Generated at Wed Jun 30 12:28:32 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.