That was my next thing to try :) BTW, would you happen to know if it is possible to set custom shell environment variables for the unit tests? My unit test requires the usage of a third party library that uses shell variables to find some shared libraries. I can't really set them before running the build because different unit tests will require different values for the same shell variable.
does the "test" section allows to set shell variables? Thanks! Jp On Wed, Jul 27, 2011 at 3:15 PM, Rene Groeschke <[email protected]> wrote: > Hi jean, > if you use groovy for your tests, you may replace > > > apply plugin:'java-base' > apply plugin:'groovy' > > with apply :'groovy-base' > > regards, > René > > Am 27.07.11 21:03, schrieb jean-philippe robichaud: > > 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 >> >> >> > > > -- > ----------------------- > regards René > > rene groeschkehttp://www.breskeby.com > @breskeby > >
