How to get project.sourceSets.main.runtimeClasspath from within a custom plugin?

Hi,

I’m writing a custom plugin that deploys an application and runs smoke tests against it. I’m having some trouble figuring out how to run the smoke tests with the appropriate classpath and configuration.

The plugin adds a custom source set named smoketest and then the project author can add the required dependencies in their project build file, like so:

dependencies {
    smoketestCompile "org.testng:testng:$testngVersion"
}

The plugin is written in Java. How do I get hold of project.sourceSets.smoketest.runtimeClasspath

Found the answer here:
http://www.programcreek.com/java-api-examples/index.php?api=org.gradle.api.tasks.SourceSet

Looks something like this:

    final JavaPluginConvention javaPlugin = getProject().getConvention().getPlugin(JavaPluginConvention.class);
    final SourceSetContainer sourceSets = javaPlugin.getSourceSets();
    final SourceSet smoketest = sourceSets.findByName("smoketest");
    this.testClasspath = smoketest.getRuntimeClasspath();