# Automatically building custom source sets from the default build task

**URL:** <https://discuss.gradle.org/t/automatically-building-custom-source-sets-from-the-default-build-task/4661>\
**Category:** Old Forum Archive\
**Created:** [March 8, 2013, 4:26pm UTC](https://discuss.gradle.org/t/automatically-building-custom-source-sets-from-the-default-build-task/4661 "2013-03-08T16:26:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brad](https://avatars.discourse-cdn.com/v4/letter/b/59ef9b/32.png) [@Brad](https://discuss.gradle.org/u/Brad)\
**Post date:** [March 8, 2013, 4:26pm UTC](https://discuss.gradle.org/t/automatically-building-custom-source-sets-from-the-default-build-task/4661/1 "2013-03-08T16:26:00Z")

</div>

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

```gradle
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.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [March 8, 2013, 7:29pm UTC](https://discuss.gradle.org/t/automatically-building-custom-source-sets-from-the-default-build-task/4661/2 "2013-03-08T19:29:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Brad](https://avatars.discourse-cdn.com/v4/letter/b/59ef9b/32.png) [@Brad](https://discuss.gradle.org/u/Brad)\
**Post date:** [March 11, 2013, 1:27pm UTC](https://discuss.gradle.org/t/automatically-building-custom-source-sets-from-the-default-build-task/4661/3 "2013-03-11T13:27:00Z")

</div>

That was exactly what I was looking for. Thanks!
