Search in sources :

Example 1 with EtaProjectDependency

use of com.typelead.gradle.eta.api.EtaProjectDependency 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);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) EtaProjectDependency(com.typelead.gradle.eta.api.EtaProjectDependency) EtaGitDependency(com.typelead.gradle.eta.api.EtaGitDependency) Project(org.gradle.api.Project) EtaDependency(com.typelead.gradle.eta.api.EtaDependency) ArrayList(java.util.ArrayList) EtaDirectDependency(com.typelead.gradle.eta.api.EtaDirectDependency) SourceRepository(com.typelead.gradle.eta.api.SourceRepository)

Example 2 with EtaProjectDependency

use of com.typelead.gradle.eta.api.EtaProjectDependency 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;
}
Also used : EtaProjectDependency(com.typelead.gradle.eta.api.EtaProjectDependency) Project(org.gradle.api.Project) EtaConfiguration(com.typelead.gradle.eta.api.EtaConfiguration) Configuration(org.gradle.api.artifacts.Configuration) EtaDependency(com.typelead.gradle.eta.api.EtaDependency) ArrayList(java.util.ArrayList)

Example 3 with EtaProjectDependency

use of com.typelead.gradle.eta.api.EtaProjectDependency in project gradle-eta by typelead.

the class DefaultEtaConfiguration method getAllArtifacts.

@Override
public Set<Provider<File>> getAllArtifacts(final Project project) {
    Set<Provider<File>> allArtifacts = new LinkedHashSet<Provider<File>>();
    allArtifacts.addAll(artifacts);
    for (EtaDependency dependency : getDependencies()) {
        if (dependency instanceof EtaProjectDependency) {
            final EtaProjectDependency projectDependency = ((EtaProjectDependency) dependency);
            final EtaConfiguration etaConfiguration = ConfigurationUtils.getEtaConfiguration(projectDependency.getProject(project), projectDependency.getTargetConfiguration());
            if (etaConfiguration != null) {
                allArtifacts.addAll(etaConfiguration.getAllArtifacts(project));
            }
        }
    }
    for (Configuration configuration : parentConfiguration.getExtendsFrom()) {
        final EtaConfiguration etaConfiguration = ExtensionHelper.getExtension(configuration, EtaConfiguration.class);
        allArtifacts.addAll(etaConfiguration.getAllArtifacts(project));
    }
    return allArtifacts;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) EtaProjectDependency(com.typelead.gradle.eta.api.EtaProjectDependency) EtaConfiguration(com.typelead.gradle.eta.api.EtaConfiguration) Configuration(org.gradle.api.artifacts.Configuration) EtaDependency(com.typelead.gradle.eta.api.EtaDependency) EtaConfiguration(com.typelead.gradle.eta.api.EtaConfiguration) File(java.io.File) Provider(org.gradle.api.provider.Provider)

Example 4 with EtaProjectDependency

use of com.typelead.gradle.eta.api.EtaProjectDependency in project gradle-eta by typelead.

the class DependencyUtils method foldEtaDependencies.

public static void foldEtaDependencies(final Project project, final Collection<EtaDependency> dependencies, final QuadConsumer<List<String>, List<String>, List<String>, Set<SourceRepository>> directProjectConsumer) {
    List<String> directDependencies = new ArrayList<>();
    List<String> projectDependencies = new ArrayList<>();
    List<String> gitStringDependencies = 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(NamingScheme.getPackageName(targetProject, SourceSet.MAIN_SOURCE_SET_NAME));
            }
        } else if (dependency instanceof EtaGitDependency) {
            final EtaGitDependency gitDep = (EtaGitDependency) dependency;
            gitDependencies.add(gitDep.getSourceRepository());
            gitStringDependencies.add(gitDep.getPackageName());
        }
    }
    if (directProjectConsumer != null) {
        directProjectConsumer.accept(directDependencies, projectDependencies, gitStringDependencies, gitDependencies);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) EtaProjectDependency(com.typelead.gradle.eta.api.EtaProjectDependency) EtaGitDependency(com.typelead.gradle.eta.api.EtaGitDependency) Project(org.gradle.api.Project) EtaDependency(com.typelead.gradle.eta.api.EtaDependency) ArrayList(java.util.ArrayList) EtaDirectDependency(com.typelead.gradle.eta.api.EtaDirectDependency) SourceRepository(com.typelead.gradle.eta.api.SourceRepository)

Aggregations

EtaDependency (com.typelead.gradle.eta.api.EtaDependency)4 EtaProjectDependency (com.typelead.gradle.eta.api.EtaProjectDependency)4 ArrayList (java.util.ArrayList)3 LinkedHashSet (java.util.LinkedHashSet)3 Project (org.gradle.api.Project)3 EtaConfiguration (com.typelead.gradle.eta.api.EtaConfiguration)2 EtaDirectDependency (com.typelead.gradle.eta.api.EtaDirectDependency)2 EtaGitDependency (com.typelead.gradle.eta.api.EtaGitDependency)2 SourceRepository (com.typelead.gradle.eta.api.SourceRepository)2 Configuration (org.gradle.api.artifacts.Configuration)2 File (java.io.File)1 Provider (org.gradle.api.provider.Provider)1