On 14/10/2010, at 5:20 PM, tinca wrote:

> 
> I am struggling with this, too.
> 
> 1. Trying the advice above:
> 
> * What went wrong:
> A problem occurred evaluating root project 'PSMC'.
> Cause: Could not find property 'test2' on root project 'PSMC'.
> 
> This is cretainly due to the forward reference to a still non-existing task
> definition.
> 2. So let's try:
> test(dependsOn: 'test2') {
>    useJUnit();
> }

You can't configure an existing task using a map and a closure like the above. 
Instead, you need to use a closure. For example:

test {
    dependsOn 'test2'
    useJUnit()  // this is the default, you don't really need it
}

You can also just the test property:

test.dependsOn 'test2'
test.useJUnit()


> 
> * What went wrong:
> A problem occurred evaluating root project 'PSMC'.
> Cause: Could not find method test() for arguments [{dependsOn=test2},
> build_gradle_1cc3d5ab16c36a6c5824412cf2666a0c$_run_closur...@c6b8b0] on root
> project 'PSMC'.
> 
> 3. OK, try other way:
> test {
>    useJUnit();
> }
> 
> task test2(type: Test) {
>    useTestNG();
> }
> test.dependsOn test2
> 
> FAILURE: Build failed with an exception.
> 
> * What went wrong:
> A base directory must be specified in the task or via a method argument!


This is http://jira.codehaus.org/browse/GRADLE-1090

A workaround is to set some additional properties of test2:

task test2(type: Test) {
    useTestNG()
    testClassesDir = test.testClassesDir
    classpath = test.classpath
}


--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz

Reply via email to