On 17/06/2011, at 3:35 AM, phil swenson wrote:

> I'm on gradle 1.0 m3.  I was trying to write a unit test for one of my
> gradle tasks and get an NPE on creation.
> 
> 
> Basically this call:
>  L10NJarTask task = new L10NJarTask()
> 
> caused this:
> 
> java.lang.NullPointerException
> 
> So looking at the gradle code, it appears any descendants of
> DefaultTask should not be constructed directly.  So in this case, how
> should I construct?  And how would I get a handle to the instance so I
> can test it?


Hi Phil,

The solution is to use the ProjectBuilder to get hold of a project and then 
create a task from it.

import org.gradle.testfixtures.ProjectBuilder
Project project = ProjectBuilder.builder().build()
L10NJarTask task = project.task("l10n", type: L10NJarTask)

-- 
Luke Daley
Principal Engineer, Gradleware 
http://gradleware.com

Please vote Gradle for JAX Awards ยป http://vote.jax-awards.com




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

    http://xircles.codehaus.org/manage_email


Reply via email to