It was longer than that though. He also spent the years developing Star Wars underworld, working on Clone Wars. He started writing Phantom Menace in Nov 1st 1994, and sold to Disney in Oct 30th 2012.
Not to mention he made a 4th Indiana Jones film, and also Red Tails and Strange Magic.
From what we’ve been told Lucas was working on the Star Wars sequel treatments before he sold Lucasfilm. He hired writers to develop them into full screenplays. Obvious that never happened due to some decision made by Kathy Kennedy or Iger.
I really don’t blame him for selling though 3 decades doing Star Wars without a break would be a bit much if the sequels took ten years.
Remember he also had plans to make a 5th Indiana Jones and to do a Willow sequel, and a bunch of personal experimental films and never did them. Probably due to him being one person and time and not for lack of interest.
He works so slow look how long it took to get the prequel trilogy and Crystal Skull made. We were lucky with the output he gave us because he set himself an unachievable impossible goal.