There's lots of variations for the Jeep 4.0 engines due to casting differences for accessories. You'll want the exact one to get everything reassembled and bolted on correctly. These are the year brackets we're aware of that you want to land on to have a straight swap.
Also you'll need an "S" Vin block. 99-00 WJ is a direct swap. 01-04 WJ will require you to swap your sensors and oil sender and starter plug. 01-06 wrangler long block requiring you to swap all your accessories onto it.
93-95 Grand Cherokee
96-98 Grand Cherokee
99-00 Grand Cherokee
01-04 Grand Cherokee