Search in sources :

Example 1 with ImmutableDAG

use of com.typelead.gradle.utils.ImmutableDAG 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 '" + parentConfiguration.getIncoming().getPath() + "'");
        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);
}
Also used : DomainObjectCollection(org.gradle.api.DomainObjectCollection) ExtensionHelper(com.typelead.gradle.utils.ExtensionHelper) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FileCollection(org.gradle.api.file.FileCollection) Logger(org.gradle.api.logging.Logger) EtaConfiguration(com.typelead.gradle.eta.api.EtaConfiguration) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Configuration(org.gradle.api.artifacts.Configuration) Provider(org.gradle.api.provider.Provider) EtaDependency(com.typelead.gradle.eta.api.EtaDependency) ConfigurationUtils(com.typelead.gradle.eta.internal.ConfigurationUtils) DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler) Map(java.util.Map) EtaBasePlugin(com.typelead.gradle.eta.plugins.EtaBasePlugin) LinkedHashSet(java.util.LinkedHashSet) ImmutableDAG(com.typelead.gradle.utils.ImmutableDAG) Project(org.gradle.api.Project) EtaProjectDependency(com.typelead.gradle.eta.api.EtaProjectDependency) ProjectDependency(org.gradle.api.artifacts.ProjectDependency) Set(java.util.Set) Collectors(java.util.stream.Collectors) File(java.io.File) List(java.util.List) HasPackageName(com.typelead.gradle.eta.api.HasPackageName) PackageInfo(com.typelead.gradle.utils.PackageInfo) GradleException(org.gradle.api.GradleException) EtlasMavenRepository(com.typelead.gradle.eta.internal.EtlasMavenRepository) Collections(java.util.Collections) Dependency(org.gradle.api.artifacts.Dependency) EtaConfiguration(com.typelead.gradle.eta.api.EtaConfiguration) Configuration(org.gradle.api.artifacts.Configuration) EtaDependency(com.typelead.gradle.eta.api.EtaDependency) PackageInfo(com.typelead.gradle.utils.PackageInfo) ArrayList(java.util.ArrayList) Logger(org.gradle.api.logging.Logger) HasPackageName(com.typelead.gradle.eta.api.HasPackageName) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

EtaConfiguration (com.typelead.gradle.eta.api.EtaConfiguration)1 EtaDependency (com.typelead.gradle.eta.api.EtaDependency)1 EtaProjectDependency (com.typelead.gradle.eta.api.EtaProjectDependency)1 HasPackageName (com.typelead.gradle.eta.api.HasPackageName)1 ConfigurationUtils (com.typelead.gradle.eta.internal.ConfigurationUtils)1 EtlasMavenRepository (com.typelead.gradle.eta.internal.EtlasMavenRepository)1 EtaBasePlugin (com.typelead.gradle.eta.plugins.EtaBasePlugin)1 ExtensionHelper (com.typelead.gradle.utils.ExtensionHelper)1 ImmutableDAG (com.typelead.gradle.utils.ImmutableDAG)1 PackageInfo (com.typelead.gradle.utils.PackageInfo)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Collectors (java.util.stream.Collectors)1