private Map<String, DependencyExtraInfo> getExtraMap() { Map<String, DependencyExtraInfo> dependencyExtraInfoMap = new HashMap<>(); DependencySet dependencies = project.getConfigurations().getByName("compile").getDependencies(); dependencies.forEach(new Consumer<Dependency>() { @Override public void accept(Dependency dependency) { String group = dependency.getGroup(); String name = dependency.getName(); String scope = "compile"; String type = ""; if (dependency instanceof DefaultProjectDependency) { DefaultProjectDependency projectDependency = (DefaultProjectDependency)dependency; if (projectDependency.getDependencyProject().getPlugins().hasPlugin(LibraryPlugin.class)) { type = "aar"; } } dependencyExtraInfoMap.put(group + ":" + name, new DependencyExtraInfo(type, scope)); } }); return dependencyExtraInfoMap; }
private Collection<ResolvedArtifact> doResolve(final Collection<ArtifactSpec> deps, boolean transitive) { final Configuration config = this.project.getConfigurations().detachedConfiguration().setTransitive(transitive); final DependencySet dependencySet = config.getDependencies(); deps.forEach(spec -> { if (projects.containsKey(spec.groupId() + ":" + spec.artifactId() + ":" + spec.version())) { dependencySet.add(new DefaultProjectDependency((ProjectInternal) projects.get(spec.groupId() + ":" + spec.artifactId() + ":" + spec.version()), new DefaultProjectAccessListener(), false)); } else { final DefaultExternalModuleDependency d = new DefaultExternalModuleDependency(spec.groupId(), spec.artifactId(), spec.version()); final DefaultDependencyArtifact da = new DefaultDependencyArtifact(spec.artifactId(), spec.type(), spec.type(), spec.classifier(), null); d.addArtifact(da); dependencySet.add(d); } }); if (transitive) { return config .getResolvedConfiguration() .getResolvedArtifacts(); } return config .getResolvedConfiguration() .getFirstLevelModuleDependencies() .stream() .map(dep -> dep.getModuleArtifacts()) .flatMap(artifacts -> artifacts.stream()) .collect(Collectors.toList()); }
public ProjectDependency create(ProjectInternal project, String configuration) { return instantiator.newInstance(DefaultProjectDependency.class, project, configuration, projectAccessListener, buildProjectDependencies); }
public ProjectDependency create(Project project) { return instantiator.newInstance(DefaultProjectDependency.class, project, projectAccessListener, buildProjectDependencies); }
public static void addProjectDependency(Project project, String variantName) { Task task = project.getTasks().findByName("prepare" + variantName + "Dependencies"); if (null == task){ return; } DependencySet dependencies = project.getConfigurations().getByName( AtlasPlugin.BUNDLE_COMPILE).getDependencies(); if (null == dependencies){ return; } dependencies.forEach(new Consumer<Dependency>() { @Override public void accept(Dependency dependency) { if (dependency instanceof DefaultProjectDependency){ Project subProject = ((DefaultProjectDependency)dependency).getDependencyProject(); Task assembleTask = subProject.getTasks().findByName("assembleRelease"); task.dependsOn(assembleTask); } } }); }