The 4 banger needs 4:88 gears with 33s to equal the stock gearing. It will still leave you desiring a bit more.
The 4.0 swap is doable but you have to swap everything. Wiring harness, motor mounts on the frame will have to be cut and new ones welded on, trans, transfer case, cross memeber, all of it. The trans and transfer case are different for a 2.5, they have different output shafts. The transfer case is 21 spline and the 4.0 transfer case is 23 spline. They do make an adapter. The 5 speed tranny behind the 2.5 (AX5) won’t hold up too long behind a 4.0
It is very doable, but you need to have a whole donar vehicle basically, and it’s so much work, you could consider any other motor and have the same amount of work.
With that said, the 4.0 is a good swap it’s just that it’s a good time to consider what you want in the long run due to the fact that you basically have to ditch all the stock stuff and swap everything in.
If I did not care for a V8 swap and big power, and I could pick up a running 4.0 powered XJ/TJ/ZJ for real cheap, I’d consider it.