ditto on the year. I have a TJ that i'm pulling the 4.0 out of. as far as i know you would just need to swap in the xj accessories to make it run and be configured right. shoot me a pm if you are interested. it has about 119k on the clock. it is between 140 and 150 in all the cylinders.
Yes the year matters depending on what it is going in. An 87 block/head will not be good to swap into something that is later then 91. Though a later model motor will swap into an earlier model vehicle.