Maven compiling with different JDK versions
<p>My application is split between users on Java 1.6u45 and Java 1.8.  Our problem is that we cannot specify the project system library and have two different compiler settings for the code at the same time.</p>

<p>Project Structure:</p>

<pre><code>Project &gt;
    &gt; src/main/java/com/us/javafx/... (Java 8 code)
    &gt; src/main/java/com/us/... (Java 6 code)
    &gt; src/main/resources/...
</code></pre>

<p>Our POM.xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
   &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
   &lt;groupId&gt;com.us&lt;/groupId&gt;
   &lt;artifactId&gt;PROJECT&lt;/artifactId&gt;
   &lt;version&gt;1.0.0&lt;/version&gt;
   &lt;packaging&gt;jar&lt;/packaging&gt;
   &lt;name&gt;PROJECT&lt;/name&gt;
   &lt;description&gt;DESCR&lt;/description&gt;

&lt;properties&gt;
    &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
&lt;/properties&gt;

&lt;dependencies&gt;

&lt;/dependencies&gt;

&lt;build&gt;
    &lt;plugins&gt;
        &lt;!-- Copy all dependencies to jars directory --&gt;
          &lt;plugin&gt; 
              &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt; 
                  &lt;executions&gt; 
                      &lt;execution&gt; 
                          &lt;phase&gt;package&lt;/phase&gt; 
                          &lt;goals&gt; 
                              &lt;goal&gt;copy-dependencies&lt;/goal&gt; 
                          &lt;/goals&gt; 
                          &lt;configuration&gt; 
                              &lt;outputDirectory&gt;${project.build.directory}/jars&lt;/outputDirectory&gt; 
                          &lt;/configuration&gt; 
                      &lt;/execution&gt; 
                  &lt;/executions&gt; 
          &lt;/plugin&gt;


            &lt;!-- Maven Compiler --&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                &lt;version&gt;3.3&lt;/version&gt;  
                &lt;configuration&gt;
                    &lt;!-- Necessary to avoid setting JRE on Maven project update! --&gt;
                    &lt;!-- SEE PHOTO FOR WHY THIS IS HERE --&gt;
                    &lt;source&gt;1.8&lt;/source&gt;
                    &lt;target&gt;1.8&lt;/target&gt;
                &lt;/configuration&gt;            
                &lt;executions&gt;

                    &lt;!-- Compile Java 6 directory --&gt;
                    &lt;execution&gt;
                        &lt;id&gt;java6&lt;/id&gt;
                        &lt;configuration&gt;
                            &lt;excludes&gt;
                                &lt;exclude&gt;com/us/javafx/**/*&lt;/exclude&gt;
                            &lt;/excludes&gt;
                            &lt;!-- Non working attempt to set compiler version --&gt;
                            &lt;source&gt;1.6&lt;/source&gt;
                            &lt;target&gt;1.6&lt;/target&gt;
                        &lt;/configuration&gt;
                    &lt;/execution&gt;

                    &lt;!-- Compile Java 8 directory --&gt;
                    &lt;execution&gt;
                        &lt;id&gt;java8&lt;/id&gt;
                        &lt;configuration&gt;
                            &lt;includes&gt;
                                &lt;include&gt;com/us/javafx/**/*&lt;/include&gt;
                            &lt;/includes&gt;
                            &lt;!-- Non working attempt to set compiler version --&gt;
                            &lt;source&gt;1.8&lt;/source&gt;
                            &lt;target&gt;1.8&lt;/target&gt;
                        &lt;/configuration&gt;
                    &lt;/execution&gt;

                &lt;/executions&gt;
            &lt;/plugin&gt;

            &lt;!-- Create JAR in jars folder --&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
                &lt;version&gt;2.6&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;outputDirectory&gt;${project.build.directory}/jars&lt;/outputDirectory&gt; 
                &lt;/configuration&gt;
              &lt;/plugin&gt;

        &lt;/plugins&gt;
&lt;/build&gt;
</code></pre>

<p></p>

<p>If we tell the Maven compiler plugin to use Java 1.8, Java 1.6 users get the unsupported major minor version error.  Or we tell the Maven compiler plugin to use Java 1.6 but our Java 8 code will complain about errors when performing Right Click Project > Maven > Update Project... (which causes the screen shot below):</p>

<p><a href="https://i.stack.imgur.com/myvS0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/myvS0.png" alt="enter image description here"></a></p>

<p>Is there a way we can achieve both:</p>

<p>1) Compile Java 6 and 8 code with their respective compilers</p>

<p>2) Choose Java 8 as our project's JRE System Library</p>