Object (String modelName, Project project) { if (GradleVersion.current().getBaseVersion().compareTo(GradleVersion.version("7.0")) >= 0 && project instanceof ProjectInternal) { try { DependenciesAccessors accessors = ((ProjectInternal)project).getServices().get(DependenciesAccessors.class); List<String> sources = accessors.getSources().getAsFiles().stream().map(Objects::toString).collect(Collectors.toList()); List<String> classes = accessors.getClasses().getAsFiles().stream().map(Objects::toString).collect(Collectors.toList()); return new DefaultDependencyAccessorsModel(sources, classes); } catch (UnknownServiceException | ServiceLookupException ignored) { } } return null; }