Automatically building custom source sets from the default build task


(brad.crosbyjr) #1

I’ve defined a custom java source set called itest to hold my integration tests:

sourceSets {
 itest {
  java {
   compileClasspath += main.output
   runtimeClasspath += main.output
  }
 }
}
  configurations {
 itestCompile.extendsFrom testCompile
 itestRuntime.extendsFrom testRuntime
}
  sourceSets {
 itest {
  java {
   compileClasspath += main.output
   runtimeClasspath += main.output
  }
 }
}
  configurations {
 itestCompile.extendsFrom testCompile
 itestRuntime.extendsFrom testRuntime
}
  task itest(type: Test) {
 testClassesDir = project.sourceSets.itest.output.classesDir
 classpath = project.sourceSets.itest.runtimeClasspath
}

The java plugin has created the compileItestJava/processItestResources/itestClasses tasks, but I’m at a lost of the right way to hook them (all) into the default build task so that they’re built automatically. How do I do this?

P.S. - I do not want to actually run these tests when ‘gradle test’ is run. I just want them built when build is run.


(Peter Niederwieser) #2

Try ‘check.dependsOn(itest)’ or ‘build.dependsOn(itestClasses)’ (depending on what you want).


(brad.crosbyjr) #3

That was exactly what I was looking for. Thanks!