@Nullable public GradleLibraryDependency findLibraryDependency( @NotNull final GradleLibraryDependencyId id) { final GradleModule module = findGradleModuleByName(id.getModuleName()); if (module == null) { return null; } final Ref<GradleLibraryDependency> ref = new Ref<GradleLibraryDependency>(); GradleEntityVisitor visitor = new GradleEntityVisitorAdapter() { @Override public void visit(@NotNull GradleLibraryDependency dependency) { if (id.getLibraryName().equals(dependency.getName())) { ref.set(dependency); } } }; for (GradleDependency dependency : module.getDependencies()) { dependency.invite(visitor); final GradleLibraryDependency result = ref.get(); if (result != null) { return result; } } return null; }
private static String removeDependencies(String source, List<GradleDependency> deps) { for (GradleDependency dep : deps) { if (!Strings.isNullOrEmpty(dep.getVersion()) && !Strings.isNullOrEmpty(dep.getConfigurationName())) { source = GradleSourceUtil.removeDependency(source, dep); } else { source = GradleSourceUtil.removeDirectDependency(source, dep.getGroup(), dep.getName()); } } return source; }