Build a jar for two different target JDK versions?

Suppose I want to build a jar for JDK1.8 and also compile the same code base for JDK1,5 to run on an ancient server we have,without making separate gradle projects. And then suppose I want to publish these jars. Two compile tasks, each feeding a different jar task, etc., etc. My head is starting to spin.

Is there an example of doing this?