On 6/05/10 6:00 PM, ck1125 wrote:
Hi All,

I have been trying to write tests for a plugin and read that you could use
GradleLauncher to get a handle to the Project object (a root project). I
should be grateful if anyone can help me with a sample of how this can be
done.

My approach is to use the launcher to create a root project then run my
plugin on the project and finally assert that it has achieved the desired
result.

Can anyone help me with this?

You can do something like this:

Project project = GradleLauncher.newInstance(new String[]{"-e", ""}).getBuildAnalysis().getGradle().getRootProject();
assertNotNull(project);

For this to work, you need to include everything in $gradleHome/lib in the test runtime classpath. You also need to set the gradle.home system property:

dependencies {
    testCompile gradleApi()
testRuntime fileTree(dir: "$gradle.gradleHomeDir/lib", include: '*.jar')
}

test {
    systemProperties['gradle.home'] = gradle.gradleHomeDir
}

This is all very awkward. There's a JIRA issue to make this better: http://jira.codehaus.org/browse/GRADLE-819


--
Adam Murdoch
Gradle Developer
http://www.gradle.org


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to