4

I'm able to define a sourceSet in Gradle using something like the following

sourceSets {
    unitTest {
        java {
            srcDir 'src/unitTest/java'
        }
        resources {
            srcDir 'src/unitTest/resources'
        }
    }
}

However, I do not seem to be able to define a Test source set using gradle. I can specify it manually via the UI, but when the gradle projects are refreshed, they are set again as a Source Set, rather than a Test Source Set.

Is there any way to define the source set in Gradle, and have Intellij pick up that it's a Test Source Set?

Zymus
  • 1,673
  • 1
  • 18
  • 38

1 Answers1

1

This has bugged many people, see IDEA-165647. The proposed solution there, which actually works would then look as follows:

sourceSets {
    test.java.srcDir 'src/unitTest/java'
    test.resources.srcDir 'src/unitTest/resources'

    unitTest {
        java {
            srcDir 'src/unitTest/java'
        }
        resources {
            srcDir 'src/unitTest/resources'
        }
    }
}

The difference is to add test.java.srcDir and test.resources.srcDir.

Michael Piefel
  • 18,660
  • 9
  • 81
  • 112