title: How to specify source and target compatibility in Java module?
body: <p>I have a Gradle project consisting of an Android module (the <code>com.android.library</code> plugin is applied in the <code>build.gradle</code> file) and a Java module (the <code>java</code> plugin is applied in the <code>build.gradle</code> file). Within the <code>build.gradle</code> file of the Java module I was previously specifying the source and target compatibility as follows:</p>
  
  <pre><code>apply plugin: 'java'
  
  compileJava {
      sourceCompatibility = 1.7
      targetCompatibility = 1.7
  }
  </code></pre>
  
  <p>I've just updated the project's "Android Plugin for Gradle" and "Gradle Wrapper" versions to the latest releases (2.2.3 and 3.2.1 respectively) and I'm now seeing warnings in the Java module as follows:</p>
  
  <pre><code>Access to 'sourceCompatibility' exceeds its access rights
  Access to 'targetCompatibility' exceeds its access rights
  </code></pre>
  
  <p>If I move the <code>sourceCompatibility</code> and <code>targetCompatibility</code> declarations to the root-level of the module's <code>build.gradle</code> file as follows...</p>
  
  <pre><code>apply plugin: 'java'
  
  sourceCompatibility = 1.7
  targetCompatibility = 1.7
  </code></pre>
  
  <p>... then I get warning messages telling me that the assignments are not used.</p>
  
  <p>What is the correct manner of specifying the source and target compatibility level of a Java module in the latest Gradle release?</p>