Thousands of people have. I have (not using a T5) and there's an immense amount of information out there (including on here).
I'm probably going to come off sounding like an #^$, but it's the voice of experience: You need to do a crap ton of research and reading.
Posting this kind of thread is only really going to let you find out that people have done it successfully. In order to even try to get started on your own swap, you'll need to do many, many hours of searching and reading. Everything is out there for you to find, though, that's the good news.
This is a very involved swap to do "right" and there's a *lot* that is going to depend on the year/model of your donor.
So I'm not trying to be difficult, but the kinds of questions you're asking don't have simple "social media" kinds of answers and you'll need to do the legwork yourself to figure it out more than a "yes" or "no".
There are multiple 4.0L swap threads on here (mine included) that would be a good place to start. The issue is that the details you need will depend on where your donor motor comes from. These swaps are ALL ABOUT the little details that it takes to actually make everything work once you mount the motor in the Jeep. The physical swap of getting a 4.0L into your Jeep is simple, getting everything sorted out from there is the PITA.
It can all be done, it's been done countless times before, but getting yourself educated on what is needed by searching and reading is the only way you'll get enough knowledge to make it work if you're going DIY. Start there and then we're here to help with specific questions.
I did this last winter. Big Walton is right; either do your research and then buy the engine or buy the engine and do the research.
Good news is that every part on a 4.0 is dirt cheap and available at every blue, green or red auto parts store. Pretty sure I replaced every sensor on the engine and did a new distributor, plugs and wires or less than $200.
The harness is key. I bought HESCO, which was awesome (but pricey); but glad I did.
LOVE it now that its done. Cold starts are easy.
Do note, that it makes torque much higher in the RPM band; so it might make you want to swap gears.....
The harness tower mentions is a perfect example. I used the donor harness and thinned it down the way I wanted to keep the power distribution center for powering other things in the Jeep which was basically free in that it came with the donor setup. Or you go the standalone HESCO or similar route to do a “swap harness” and spend $$$. Both work (assuming you DIY the wiring properly) but are vastly different approaches.
DIY wiring requires digging into the FSM electrical diagrams for the specific years of donor and CJ that takes research.
I am about to do this. My old and tired 4.2 is coming out and I purchased a 4.0 from a 1997 XJ that comes with an aw4 and a transfer case that I won't be using. I am going to use the dana 300 with the 4 to 1 ratio and the twin stick that I installed right before I had issues with the motor.
Now to go find Big Walton's build thread. I need to start finding parts like the auto trans control module, the euc and the harness.