Well yesterday I worked a little on the engine and got to looking. To me it looks like they designed the driver side to be either Yj or Cherokee and they just drilled the hole in a different spot. So what would keep me from just drilling a new hole to fit where I need it.
I am currently on my 3rd swap and can give you some info on this subject.
I have redrilled the motor bracket and it will work just fine, though having the XJ hole in there makes it a little weaker.
Que89YJ is correct on the wiring. The easiest way is to cut open your 2.5 engine harness and add in the 2 sets of injector wires and plugs. You will need to reposition a few wires and extend a few as well due to the added length of the 4.0. The ECU (Computer) from the XJ will bolt right in and be plug and play. I do not recall having to short the neutral safety switch, I am thinking that your clutch safety switch replaces it, but I may be wrong on that.
Your sensors from the XJ or the 2.5 will work fine.
You will need some new brackets on the front of the motor to position everything correctly for the YJ. You can reuse the 2.5 upper alternator bracket that holds the A/C compressor as it is the same for the 4.0 YJ. You will need a lower alternator bracket that is YJ specific, and not very easy to find. You will also need to change the waterpump as well as your fan, fan clutch, and fan shroud with 4.0 YJ specific parts.
You did not specify what transmission you are going to use. You cannot use the AX5 behind the 4.0. If you plan to use the auto, than thats a whole new deal as you will need to re-clock the transfer case and fabricate a mounting spot in your crossmember/bellypan just for starters. If you have obtained an AX15, than you will need the steel transmission bracket that goes between the trans & rubber mount, as well as the bellhousing (the external slave cylinder type), flywheel, & clutch. You will also need the tcase for the AX15, or swap the input shaft out in your 2.5 tcase. The AX5 rubber mount is the same for the AX15.
Your driveshafts will need lengthened/shortened as well.
Though I have never reused the frame brackets for the 2.5 to the motor, I have seen many on here that have reused them successfully.