Search in sources :

Example 1 with DefaultDependencyArtifact

use of org.gradle.api.internal.artifacts.dependencies.DefaultDependencyArtifact in project wildfly-swarm by wildfly-swarm.

the class GradleArtifactResolvingHelper method doResolve.

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());
}
Also used : Iterator(java.util.Iterator) Project(org.gradle.api.Project) DefaultProjectDependency(org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency) ResolvedArtifact(org.gradle.api.artifacts.ResolvedArtifact) Collection(java.util.Collection) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) Set(java.util.Set) DefaultProjectAccessListener(org.gradle.api.internal.project.DefaultProjectAccessListener) DependencySet(org.gradle.api.artifacts.DependencySet) Collectors(java.util.stream.Collectors) HashSet(java.util.HashSet) DefaultDependencyArtifact(org.gradle.api.internal.artifacts.dependencies.DefaultDependencyArtifact) ArtifactResolvingHelper(org.wildfly.swarm.tools.ArtifactResolvingHelper) Configuration(org.gradle.api.artifacts.Configuration) Map(java.util.Map) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) Collections(java.util.Collections) ArtifactSpec(org.wildfly.swarm.tools.ArtifactSpec) DefaultDependencyArtifact(org.gradle.api.internal.artifacts.dependencies.DefaultDependencyArtifact) Configuration(org.gradle.api.artifacts.Configuration) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) DefaultProjectDependency(org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) DependencySet(org.gradle.api.artifacts.DependencySet) DefaultProjectAccessListener(org.gradle.api.internal.project.DefaultProjectAccessListener)

Aggregations

Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Project (org.gradle.api.Project)1 Configuration (org.gradle.api.artifacts.Configuration)1 DependencySet (org.gradle.api.artifacts.DependencySet)1 ResolvedArtifact (org.gradle.api.artifacts.ResolvedArtifact)1 DefaultDependencyArtifact (org.gradle.api.internal.artifacts.dependencies.DefaultDependencyArtifact)1 DefaultExternalModuleDependency (org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency)1 DefaultProjectDependency (org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency)1 DefaultProjectAccessListener (org.gradle.api.internal.project.DefaultProjectAccessListener)1 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)1 ArtifactResolvingHelper (org.wildfly.swarm.tools.ArtifactResolvingHelper)1 ArtifactSpec (org.wildfly.swarm.tools.ArtifactSpec)1