On 5/06/10 2:15 AM, Spencer Allain wrote:
I'm playing with the infamous all-subprojects javadocs again, as my original changes for 0.9 ceased to function with preview release 3.

Arguably, I was not doing things the correct way in the first place, but it was interesting to discover why it no longer works.

alljavadoc.doFirst()
{
  Javadoc task ->
  task.project.subprojects.each  {
    Project subproject ->

    task.source = task.source + subproject.javadoc.source
    task.classpath = task.classpath + subproject.javadoc.classpath
  }
}

Now I get "Cause: Cannot invoke method plus() on null object"

Not sure if this is a DSL or groovy version change, or what.

Anyway, in attempting to find a uniform way of adding to the values, it seems that source and classpath are both set to null objects (at least as visible via the implicit get() methods).

Is there a reason that list-type objects are initialized to null (or in the case of source within SourceTask made to appear to be null) instead of treated as empty collections? I suspect it might be for performance reasons, or maybe just a style reason, but it seems inconsistent with many other collections that are initialized to empty instead of null.


Most collection properties are initialised to an empty collection, rather than null. There are a few which still are initialised to null, but the plan is to fix these. I've changed SourceTask.source and Javadoc.classpath to be initialised to an empty collection.


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

Reply via email to