@Override public void execute(ProjectDependency dep) { addSourceSet(sources, dep.getDependencyProject(), SourceSet.MAIN_SOURCE_SET_NAME); } });
private void ensureConfigured(Configuration config) { for (Dependency dependency : config.getAllDependencies()) { if (dependency instanceof ProjectDependency) { ProjectDependency projectDependency = (ProjectDependency) dependency; project.evaluationDependsOn(projectDependency.getDependencyProject().getPath()); try { ensureConfigured(projectDependency.getProjectConfiguration()); } catch (Throwable e) { throw new UnknownProjectException(String.format( "Cannot evaluate module %s : %s", projectDependency.getName(), e.getMessage()), e); } } } }
public static Iterable<TaskDependency> getTaskDependencies( Configuration configuration) { Set<TaskDependency> taskDependencies = new HashSet<>(); DependencySet dependencySet = configuration.getAllDependencies(); for (ProjectDependency projectDependency : dependencySet.withType(ProjectDependency.class)) { taskDependencies.add(projectDependency.getBuildDependencies()); } return taskDependencies; }
private void applyRecommendationToDependency(final RecommendationStrategyFactory factory, Dependency dependency, List<ProjectDependency> visited) { if (dependency instanceof ExternalModuleDependency) { factory.getRecommendationStrategy().inspectDependency(dependency); } else if (dependency instanceof ProjectDependency) { ProjectDependency projectDependency = (ProjectDependency) dependency; if (!visited.contains(projectDependency)) { visited.add(projectDependency); Configuration configuration; try { ProjectDependency.class.getMethod("getTargetConfiguration"); String targetConfiguration = projectDependency.getTargetConfiguration() == null ? Dependency.DEFAULT_CONFIGURATION : projectDependency.getTargetConfiguration(); configuration = projectDependency.getDependencyProject().getConfigurations().getByName(targetConfiguration); } catch (NoSuchMethodException ignore) { try { Method method = ProjectDependency.class.getMethod("getProjectConfiguration"); configuration = (Configuration) method.invoke(dependency); } catch (Exception e) { throw new RuntimeException("Unable to retrieve configuration for project dependency", e); } } DependencySet dependencies = configuration.getAllDependencies(); for (Dependency dep : dependencies) { applyRecommendationToDependency(factory, dep, visited); } } } }
private Set<GradleLibrary> getLibrariesForFileDependencies(Configuration configuration, LibraryScope scope) { Set<GradleLibrary> libraries = new LinkedHashSet<GradleLibrary>(); for (Dependency dependency : configuration.getIncoming().getDependencies()) { if (dependency instanceof FileCollectionDependency) { FileCollectionDependency fileDependency = (FileCollectionDependency) dependency; for (File file : fileDependency.resolve()) { libraries.add(new GradleLibrary(fileDependency.getGroup(), file, scope)); } } else if (dependency instanceof ProjectDependency) { ProjectDependency projectDependency = (ProjectDependency) dependency; libraries.addAll(getLibrariesForFileDependencies(projectDependency.getProjectConfiguration(), scope)); } } return libraries; }
private void populateEtaConfiguration(final Configuration configuration) { final DefaultEtaConfiguration etaConfiguration = ExtensionHelper.createExtension (configuration, ETA_CONFIGURATION_EXTENSION_NAME, DefaultEtaConfiguration.class, configuration, mavenRepository); Set<EtaDependency> dependencies = etaConfiguration.getDependencies(); configuration.getDependencies().all (dependency -> { if (dependency instanceof ProjectDependency) { final ProjectDependency projectDependency = (ProjectDependency) dependency; dependencies.add(new DefaultEtaProjectDependency (projectDependency.getDependencyProject(), projectDependency.getTargetConfiguration())); } else if (dependency instanceof EtaDependency) { dependencies.add((EtaDependency) dependency); } }); }
@Override public void execute(ProjectDependency dep) { addSourceSet(sources, dep.getDependencyProject(), SourceSet.MAIN_SOURCE_SET_NAME); } });
@Override public List<Buildable> call() { return getProject().getConfigurations() .getByName(getTargetConfiguration()) .getAllDependencies().stream() .filter(dependency -> dependency instanceof ProjectDependency) .flatMap(dependency -> { final ProjectDependency projectDependency = (ProjectDependency) dependency; final Project project = projectDependency.getDependencyProject(); final String configurationName = projectDependency.getTargetConfiguration(); return ConfigurationUtils.getConfiguration (project, configurationName) .getAllArtifacts().stream(); }) .collect(Collectors.toList()); } });
public boolean contentEquals(Dependency dependency) { if (this == dependency) { return true; } if (dependency == null || getClass() != dependency.getClass()) { return false; } ProjectDependency that = (ProjectDependency) dependency; if (!isCommonContentEquals(that)) { return false; } return dependencyProject.equals(that.getDependencyProject()); }
public static List<String> searchForEtaProjectDependencies (final Project project, final Configuration configuration) { List<String> allMavenDependencies = new ArrayList<String>(); for (Dependency dependency : configuration.getAllDependencies()) { if (dependency instanceof ProjectDependency) { final ProjectDependency projectDependency = (ProjectDependency) dependency; final Project targetProject = projectDependency.getDependencyProject(); final String targetConfiguration = projectDependency.getTargetConfiguration(); List<String> mavenDependencies; if (targetProject.getPlugins().hasPlugin(EtaBasePlugin.class)) { mavenDependencies = ConfigurationUtils.getEtaConfiguration (targetProject, targetConfiguration) .getAllResolvedDependencies(project); } else { mavenDependencies = searchForEtaProjectDependencies (project, ConfigurationUtils.getConfiguration (targetProject, targetConfiguration)); } allMavenDependencies.addAll(mavenDependencies); } } return allMavenDependencies; } }
/** * Collects a project's project dependencies, including all transitive project dependencies. * * @param project the project to find the project dependencies for * @return the set of project dependencies */ private static Set<ProjectDependency> findProjectDependencies(Project project) { Set<ProjectDependency> projectDependencies = new HashSet<>(); Deque<Project> projects = new ArrayDeque<>(); projects.push(project); while (!projects.isEmpty()) { Project currentProject = projects.pop(); // Search through all dependencies for (Configuration configuration : currentProject.getConfigurations().getByName("runtime").getHierarchy()) { for (Dependency dependency : configuration.getDependencies()) { if (dependency instanceof ProjectDependency) { // If this is a project dependency, save it ProjectDependency projectDependency = (ProjectDependency) dependency; if (!projectDependencies.contains(projectDependency)) { projects.push(projectDependency.getDependencyProject()); projectDependencies.add(projectDependency); } } } } } return projectDependencies; }
printProjectFiles(projectDependency.getDependencyProject()); String configurationName = projectDependency.getTargetConfiguration(); if (configurationName == null) { configurationName = "default"; Project dependencyProject = projectDependency.getDependencyProject(); for (Configuration targetConfiguration : dependencyProject.getConfigurations().getByName(configurationName).getHierarchy()) {
final ProjectDependency next = iter.next(); projectDependencyList.add(next); final String projectPath = next.getDependencyProject().getProjectDir().getAbsolutePath(); final GradleModule dependencyModule = new GradleModule(projectDependency.getDependencyProject()); projectDependencyPaths.addAll(dependencyModule.getProjectDependencies());
final ProjectDependency projectDependency = (ProjectDependency) dependency; final Project targetProject = projectDependency.getDependencyProject(); final String targetConfiguration = projectDependency.getTargetConfiguration(); List<String> mavenDependencies; if (targetProject.getPlugins().hasPlugin(EtaBasePlugin.class)) {
private Collection<File> listProjectDepsSrcDirs(Project project) { ConfigurationContainer configs = project.getConfigurations(); Configuration compileConf = configs.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME); DependencySet depSet = compileConf.getAllDependencies(); List<File> result = Lists.newArrayList(); for (Dependency dep : depSet) { if (dep instanceof ProjectDependency) { Project projectDependency = ((ProjectDependency) dep).getDependencyProject(); if (projectDependency.getPlugins().hasPlugin(GwtLibPlugin.class)) { JavaPluginConvention javaConvention = projectDependency.getConvention().getPlugin(JavaPluginConvention.class); SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); result.addAll(mainSourceSet.getAllSource().getSrcDirs()); } } } return result; }
private Collection<File> listProjectDepsSrcDirs(Project project) { ConfigurationContainer configs = project.getConfigurations(); Configuration compileConf = configs.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME); DependencySet depSet = compileConf.getAllDependencies(); List<File> result = Lists.newArrayList(); for (Dependency dep : depSet) { if (dep instanceof ProjectDependency) { Project projectDependency = ((ProjectDependency) dep).getDependencyProject(); if (projectDependency.getPlugins().hasPlugin(PwtLibPlugin.class)) { JavaPluginConvention javaConvention = projectDependency.getConvention().getPlugin(JavaPluginConvention.class); SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); result.addAll(mainSourceSet.getAllSource().getSrcDirs()); } } } return result; }
if (dependency instanceof ProjectDependency) { org.gradle.api.Project p = ((ProjectDependency) dependency).getDependencyProject(); if (p != null) { Project lintProject = getProject(lintClient, p.getName(), p,
if (dependency instanceof ProjectDependency) { org.gradle.api.Project p = ((ProjectDependency) dependency).getDependencyProject(); if (p != null) {
private void configureOverlay(WarOverlay overlay) { if (overlay.isDeferProvidedConfiguration()) { //Delay this to trick IntelliJ overlay.getWarTask().doFirst(w -> overlay.getWarCopySpec().exclude(element -> overlay.isProvided())); } else { overlay.getWarCopySpec().exclude(element -> overlay.isProvided()); } Object source = overlay.getSource(); if (source instanceof AbstractArchiveTask) { configureOverlay(overlay, (AbstractArchiveTask) source); } else if (source instanceof Project && overlay.getConfigureClosure() == null) { configureOverlay(overlay, (Project) source); } else { Closure configClosure = overlay.getConfigureClosure(); Dependency dependency; if (configClosure == null) { dependency = project.getDependencies().create(source); } else { dependency = project.getDependencies().create(source, configClosure); } if (dependency instanceof ProjectDependency) { configureOverlay(overlay, ((ProjectDependency) dependency).getDependencyProject()); } else if (dependency instanceof ExternalDependency) { configureOverlay(overlay, (ExternalDependency) dependency); } else { throw new GradleException("Unsupported dependency type: " + dependency.getClass().getName()); } } }