public function getReferencedObject(Project $fallback = null)
    {
        $project = $fallback ?? $this->project;

        if ($this->refid === null) {
            throw new BuildException("No reference specified");
        }
        $o = $project->getReference($this->refid);
        if ($o === null) {
            throw new BuildException("Reference {$this->refid} not found.");
        }

        return $o;
    }