@Nullable
  @Override
  public String getMainClassFromJarPlugin() {
    Jar jarTask = (Jar) project.getTasks().findByName("jar");
    if (jarTask == null) {
      return null;
    }

    Object value = jarTask.getManifest().getAttributes().get("Main-Class");

    if (value instanceof Provider) {
      value = ((Provider<?>) value).getOrNull();
    }

    if (value instanceof String) {
      return (String) value;
    }

    if (value == null) {
      return null;
    }

    return String.valueOf(value);
  }
@Test
  public void testGetMainClassFromJarAsPropertyWithValueNull_missing() {
    Property<String> mainClass = project.getObjects().property(String.class).value((String) null);

    Jar jar = project.getTasks().withType(Jar.class).getByName("jar");
    jar.setManifest(new DefaultManifest(null).attributes(ImmutableMap.of("Main-Class", mainClass)));

    assertThat(gradleProjectProperties.getMainClassFromJarPlugin()).isNull();
  }