Setting JAVA_HOME for atlas-run for different branches of my plugin for Jira 7 and 8

I have two branches of my plugin for Jira 7 and 8. Because Jira 7 and 8 require different Java versions, I am looking for a way to configure in the pom.xml the JDK for compile and JRE for atlas-run, so that I use automatically the right JDK and JRE for atlas-package and atlas-run.

Any ideas how to do the trick in pom.xml? Or any other ideas?