use of com.typelead.gradle.eta.api.EtaDependency in project gradle-eta by typelead.
the class DefaultEtaConfiguration method doResolve.
public void doResolve(final Project project, final DependencyHandler handler, final ImmutableDAG<String, PackageInfo> dependencyGraph, Set<String> resolvedDependencies) {
final Logger logger = project.getLogger();
final String configurationName = parentConfiguration.getName();
Set<String> resolvedDeps = new HashSet<String>();
for (Configuration configuration : parentConfiguration.getExtendsFrom()) {
DefaultEtaConfiguration etaConfiguration = ExtensionHelper.getExtension(configuration, DefaultEtaConfiguration.class);
etaConfiguration.doResolve(project, handler, dependencyGraph, resolvedDeps);
}
List<String> keys = new ArrayList<String>();
for (EtaDependency dep : dependencies) {
if (dep instanceof HasPackageName) {
keys.add(((HasPackageName) dep).getPackageName());
}
}
if (!resolved.get() && resolved.compareAndSet(false, true)) {
logger.info("Resolving Eta Configuration '" + configurationName + "'");
List<PackageInfo> packageInfos = dependencyGraph.differenceClosure(keys, resolvedDeps);
if (packageInfos.size() > 0) {
mavenRepository.installPackages(packageInfos, dependencyGraph);
resolvedMavenDependencies = packageInfos.stream().filter(packageInfo -> keys.contains(packageInfo.getName())).map(mavenRepository::getMavenDependency).collect(Collectors.toList());
for (String mavenDep : resolvedMavenDependencies) {
handler.add(configurationName, mavenDep);
logger.info("Injecting maven dependency '" + mavenDep + "'");
}
} else {
resolvedMavenDependencies = Collections.emptyList();
}
}
resolvedDependencies.addAll(resolvedDeps);
resolvedDependencies.addAll(keys);
}
use of com.typelead.gradle.eta.api.EtaDependency in project gradle-eta by typelead.
the class DefaultEtaConfiguration method getAllDependencies.
@Override
public Set<EtaDependency> getAllDependencies() {
Set<EtaDependency> allDependencies = new LinkedHashSet<>();
allDependencies.addAll(dependencies);
for (Configuration configuration : parentConfiguration.getExtendsFrom()) {
EtaConfiguration etaConfiguration = ExtensionHelper.getExtension(configuration, EtaConfiguration.class);
allDependencies.addAll(etaConfiguration.getAllDependencies());
}
return allDependencies;
}
use of com.typelead.gradle.eta.api.EtaDependency in project gradle-eta by typelead.
the class DependencyUtils method foldEtaDependencies.
public static void foldEtaDependencies(final Project project, Collection<EtaDependency> dependencies, BiConsumer<List<String>, List<String>> directProjectConsumer, Consumer<Set<SourceRepository>> gitConsumer) {
List<String> directDependencies = new ArrayList<>();
List<String> projectDependencies = new ArrayList<>();
Set<SourceRepository> gitDependencies = new LinkedHashSet<>();
for (EtaDependency dependency : dependencies) {
if (dependency instanceof EtaDirectDependency) {
directDependencies.add(((EtaDirectDependency) dependency).toString());
} else if (dependency instanceof EtaProjectDependency) {
final Project targetProject = ((EtaProjectDependency) dependency).getProject(project);
if (isEtaProject(targetProject)) {
projectDependencies.add(targetProject.getName());
}
} else if (dependency instanceof EtaGitDependency) {
gitDependencies.add(((EtaGitDependency) dependency).getSourceRepository());
}
}
if (directProjectConsumer != null) {
directProjectConsumer.accept(directDependencies, projectDependencies);
}
if (gitConsumer != null) {
gitConsumer.accept(gitDependencies);
}
}
use of com.typelead.gradle.eta.api.EtaDependency in project gradle-eta by typelead.
the class EtaBasePlugin method populateEtaConfiguration.
private void populateEtaConfiguration(final Configuration configuration) {
final DefaultEtaConfiguration etaConfiguration = ExtensionHelper.createExtension(configuration, ETA_CONFIGURATION_EXTENSION_NAME, DefaultEtaConfiguration.class, configuration, mavenRepository);
DomainObjectCollection<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);
}
});
}
use of com.typelead.gradle.eta.api.EtaDependency in project gradle-eta by typelead.
the class DefaultEtaConfiguration method getAllResolvedDependencies.
@Override
public List<String> getAllResolvedDependencies(final Project project) {
List<String> allResolvedDependencies = new ArrayList<String>(getResolvedDependencies());
for (EtaDependency dependency : dependencies) {
if (dependency instanceof EtaProjectDependency) {
final EtaProjectDependency projectDependency = (EtaProjectDependency) dependency;
final Project targetProject = projectDependency.getProject(project);
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));
}
allResolvedDependencies.addAll(mavenDependencies);
}
}
for (Configuration configuration : parentConfiguration.getExtendsFrom()) {
allResolvedDependencies.addAll(ConfigurationUtils.getEtaConfiguration(configuration).getAllResolvedDependencies(project));
}
return allResolvedDependencies;
}
Aggregations