Thanks René, that's working beautifully.
For the records, here is my build.gradle file. I've actually put the "test"
feature into a separate project (instead of embedding it into each
subprojects). I've also enabled the "groovy" plugin since it is so much
easier to write my test in groovy...
build.gradle:
apply plugin:'java-base'
apply plugin:'groovy'
repositories{
mavenCentral()
}
configurations {
testCompile { extendsFrom compile }
testRuntime { extendsFrom testCompile, runtime }
}
sourceSets {
test {
compileClasspath = configurations.testCompile
runtimeClasspath = classes + configurations.testRuntime
groovy {
srcDir = "src/test/groovy"
}
}
}
dependencies{
groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.8.0'
testCompile "junit:junit:4.8.2"
}
test {
systemProperties 'basedir': project.projectDir;
}
Again, thanks!
Jp
On Tue, Jul 19, 2011 at 4:55 PM, Rene Groeschke <[email protected]> wrote:
> Hi,
> the easiest way to add junit infrastructure to your project is to use the
> java-base plugin instead of the java plugin. Applying the base java plugin,
> you have to define the sourcesets and test task on your own. The following
> snippet adds a test task and the according compile tasks for a sourceset
> that contains your tests only. no productive java sourceset is defined:
> ----------------------
> apply plugin:'java-base'
>
> repositories{
> mavenCentral()
> }
> configurations {
> testCompile { extendsFrom compile }
> testRuntime { extendsFrom testCompile, runtime }
> }
>
> sourceSets {
> test {
> compileClasspath = configurations.testCompile
> runtimeClasspath = classes + configurations.testRuntime
> }
> }
>
> dependencies{
> testCompile "junit:junit:4.8.2"
> }
>
> task test(type:Test){
> testClassesDir = sourceSets.test.classesDir
> classpath = compileTestJava.outputs.files + configurations.testRuntime
> }
> ----------------------
>
> now executing gradle test should do the trick.
>
> regards,
> René
>
> Am 19.07.11 20:54, schrieb jean-philippe robichaud:
>
> Hi everyone.
>>
>> I've relatively new to Gradle and I'm using it successfully for my
>> non-java project. We are building "grammars" using various custom perl &
>> groovy scripts and I manage to rapidly wrap a build system thanks to Gradle
>> (very good tool btw!). We're using the 'multi-project' approach where each
>> artifact is build by one project. Overall, it's pretty clean.
>>
>> Now I would like to use junit tests to perform various validation and
>> verification steps on the many grammars produced. Is there a way I could
>> 'recycle' the 'test' infrastructure to be able to produce junit tests and
>> profit for the built-in reports? From what I understood, that's tied to the
>> 'java' plugin (which I'm not using because I'm not compiling java code).
>>
>> Thanks for your help!
>>
>> Jp
>>
>
>
> --
> -----------------------
> regards René
>
> rene groeschke
> http://www.breskeby.com
> @breskeby
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe from this list, please visit:
>
>
> http://xircles.codehaus.org/**manage_email<http://xircles.codehaus.org/manage_email>
>
>
>