It was built around the spore technology, presumably before the war, but apparently not by Starfleet. Starfleet than commandeered the two scientists, the two spin drive ships, stuck them all together, and gave one to Lorca.
Otherwise, Starfleet picked up Stamets and his spore research buddy, told them "You work for us now." Then, built two spore drive ships, around these two guy's research, and had them completed in less than 6 months.
Choose your pain.
I think, given Trek technology, that you could build an already designed ship in about 6 months.
But I have to point out a few things.
1) As far as we know, Starfleet is the organization that builds starships for the Federation (or at least the corps of engineers). There are the the occasional Vulcan ship (like the transport Sarek used in "Lethe"), occasional other civilian transports, or Mudd's father-in-law's ship, but we don't really see any "starship class" ships that don't look like they came out of the Starfleet assembly line. Additionally, that someone else would have built three ships (since the Crossfield itself is still out there somewhere) to Starfleet specs (because the Discovery and the Glenn are totally Starfleet designs) seems unlikely.
2) Just because the war began ~6 months before we saw the Discovery/Glenn first, doesn't mean they were only built in that timeframe. I don't remember any dialog that says they were only built since it started - Starfleet likely started to build the two ships to test the technology before the war, and fast tracked them to get them done pronto. Maybe they even simply converted one or both of the ships for spore drive testing purposes, because other than the spinning section of the primary hull, it isn't clear that there are any spore-drive-specific design elements.
Now for my question about the spore drive: how are the showrunners/writers going to make the sporedrive non-viable for the future?
Originally I had thought they were going to get the drive working just long enough to get a couple of missions completed, helping to win the war, but simultaneously realizing that the drive wasn't viable for anthing other than a one-time war winning need (and even then it would have to come at great cost, like a 90% chance of a failed jump).
Then I thought they would hinge it on needing the Tardigrade and only having the one, who would die or disappear. But now that Stamets can do it too with only a little genetic injection, that is not a limitation.
And now we have seen Discovery make at least 140 jumps, and until this last one there has been only one other accident (with the Glenn) and it was corrected. So there goes the "unreliable technology" option as well as the "somehow damages the crew or subspace" option.
Maybe it will be the genetic tampering that blocks it - but that would only make it a non-starter for the Federation with its "no eugenics" law, any other power should quickly be able to adopt it.
Maybe this "sideways" jump into this alternate universe is what makes the drive non-viable - I think that is the only remaining viable option. And even then, it again comes down to a "regulatory" limit, not a physical one. Starfleet can classify the information, but others know about it and it would only be a matter of time before another galactic power rediscovered the concept.
Can't wait to find out.
Anyone have thoughts on this?