PZ Myers has a nice discussion of the convergent evolution of the synthesis of caffeine (separately evolved at least 5 times!), based on the paper from PNAS, Convergent evolution of caffeine in plants by co-option of exapted ancestral enzymes, by Huang, O’Donnell, Barboline, and Barkman.
Biologists used to think that there was one canonical pathway for caffeine synthesis, from xanthosine through 7-methylxanthine and theobromine to caffeine. The paper shows that some plants use a different pathway (through 3-methylxanthine and theophylline) and that the enzymes used even on the common pathways are different.
The evolutionary model that best explains the data is that ancestral enzymes were promiscuous (which means that they had several different functions, not that they were sexual) and were eventually duplicated and specialized for caffeine production. The researchers reconstructed some of the ancestral enzymes from the modern descendants and confirmed that this hypothesis was reasonable, as only single amino-acid substitutions were necessary to confer the two different specificities of the modern enzymes from the ancestral ones.