@Override
  public int getMajorJavaVersion() {
    JavaVersion version = JavaVersion.current();
    JavaPluginExtension javaPluginExtension =
        project.getExtensions().findByType(JavaPluginExtension.class);
    if (javaPluginExtension != null) {
      version = javaPluginExtension.getTargetCompatibility();
    }
    return Integer.valueOf(version.getMajorVersion());
  }
@Test
  public void testGetMajorJavaVersion() {
    JavaPluginExtension extension = project.getExtensions().findByType(JavaPluginExtension.class);

    extension.setTargetCompatibility(JavaVersion.VERSION_1_3);
    assertThat(gradleProjectProperties.getMajorJavaVersion()).isEqualTo(3);

    extension.setTargetCompatibility(JavaVersion.VERSION_11);
    assertThat(gradleProjectProperties.getMajorJavaVersion()).isEqualTo(11);

    extension.setTargetCompatibility(JavaVersion.VERSION_1_9);
    assertThat(gradleProjectProperties.getMajorJavaVersion()).isEqualTo(9);
  }