Running java class from gradle build script

Not really. I can only make it work if I do it in the afterEvaluate scope and on the main sourceSet:

afterEvaluate{
  main = 'com.MyMain'
  classpath=sourceSets.main.runtimeClasspath
//
classpath=configurations.runtime , does not work
  println "the classpath: "
  classpath.each { println it }
 }

With the above it finds the class but I get another error that a .properties file cannot be found which is located the test resources (I know that this should only be used when running tests):

test {
  java {
   srcDir 'test'
  }
  resources {
   srcDir 'testResources'
  }
 }

Therefore I have added the test resources like this:

afterEvaluate{
  main = 'com.MyMain'
  classpath=sourceSets.main.runtimeClasspath
  classpath=+sourceSets.test.resources
//
classpath=configurations.runtime , does not work
  println "the classpath: "
  classpath.each { println it }
 }

but it gives an error:

groovy.lang.MissingMethodException: No signature of method: org.gradle.api.internal.file.DefaultSourceDirectorySet.positive() is applicable for argument types: ()

Any suggestions on how to include resources from the test sourceSet when running the above class?