There is a LOT of work that goes into it ... but I'd go ahead and buy the motor/ECU if I was in your position and I had the money. That way, when you've saved up some cash and you're absolutely ready to do the swap you've already got the two most important components. On the other hand, if your 4.0L is doing fine I really don't see the need to swap unless you want to get into racing or you're building a hardcore rock crawler.
But yes, excluding the motor and including a transmission to mate it with that swap will probably cost you anywhere from $1,500 to $3,000. There will be some fabrication and lots of special-order parts involved, along with lots of headaches to work through (like where the hell to route dual exhaust pipes

) There is a site dedicated to selling parts and adapters for Jeep engine swaps but I cannot remember the URL off-hand, I'm sure someone else will.
Good luck