use of org.apache.maven.shared.artifact.resolve.ArtifactResult in project maven-plugins by apache.
the class DefaultDependencyResolver method updateDependencySetResolutionRequirements.
void updateDependencySetResolutionRequirements(final DependencySet set, final ResolutionManagementInfo requirements, AssemblyId assemblyId, ProjectBuildingRequest buildingRequest, final MavenProject... projects) throws DependencyResolutionException {
requirements.setResolutionRequired(true);
requirements.setResolvedTransitively(set.isUseTransitiveDependencies());
ScopeFilter scopeFilter = FilterUtils.newScopeFilter(set.getScope());
requirements.setScopeFilter(scopeFilter);
for (final MavenProject project : projects) {
if (project == null) {
continue;
}
Set<Artifact> dependencyArtifacts = project.getDependencyArtifacts();
if (dependencyArtifacts == null) {
try {
Iterable<ArtifactResult> artifactResults = dependencyResolver.resolveDependencies(buildingRequest, project.getModel(), scopeFilter);
dependencyArtifacts = new HashSet<Artifact>();
for (ArtifactResult artifactResult : artifactResults) {
dependencyArtifacts.add(artifactResult.getArtifact());
}
project.setDependencyArtifacts(dependencyArtifacts);
} catch (final DependencyResolverException e) {
throw new DependencyResolutionException("Failed to create dependency artifacts for resolution. Assembly: " + assemblyId, e);
}
}
requirements.addArtifacts(dependencyArtifacts);
getLogger().debug("Dependencies for project: " + project.getId() + " are:\n" + StringUtils.join(dependencyArtifacts.iterator(), "\n"));
}
}
use of org.apache.maven.shared.artifact.resolve.ArtifactResult in project maven-plugins by apache.
the class DefaultRepositoryAssembler method buildRemoteRepository.
public void buildRemoteRepository(File repositoryDirectory, RepositoryInfo repository, RepositoryBuilderConfigSource configSource) throws RepositoryAssemblyException {
MavenProject project = configSource.getProject();
ProjectBuildingRequest buildingRequest = configSource.getProjectBuildingRequest();
Iterable<ArtifactResult> result = null;
Collection<Dependency> dependencies = project.getDependencies();
if (dependencies == null) {
Logger logger = getLogger();
if (logger.isDebugEnabled()) {
logger.debug("dependency-artifact set for project: " + project.getId() + " is null. Skipping repository processing.");
}
return;
}
Collection<Dependency> managedDependencies = null;
if (project.getDependencyManagement() != null) {
managedDependencies = project.getDependencyManagement().getDependencies();
}
// Older Aether versions use an cache which can't be cleared. So can't delete repoDir and use it again.
// Instead create a temporary repository, delete it at end (should be in a finally-block)
File tempRepo = new File(repositoryDirectory.getParentFile(), repositoryDirectory.getName() + "_tmp");
buildingRequest = repositoryManager.setLocalRepositoryBasedir(buildingRequest, tempRepo);
try {
result = dependencyResolver.resolveDependencies(buildingRequest, dependencies, managedDependencies, null);
} catch (DependencyResolverException e) {
throw new RepositoryAssemblyException("Error resolving artifacts: " + e.getMessage(), e);
}
ArtifactFilter filter = buildRepositoryFilter(repository, project);
buildingRequest = repositoryManager.setLocalRepositoryBasedir(buildingRequest, repositoryDirectory);
Map<String, GroupVersionAlignment> groupVersionAlignments = createGroupVersionAlignments(repository.getGroupVersionAlignments());
assembleRepositoryArtifacts(buildingRequest, result, filter, groupVersionAlignments);
if (repository.isIncludeMetadata()) {
// assembleRepositoryMetadata( result, filter, centralRepository, targetRepository );
}
try {
FileUtils.deleteDirectory(tempRepo);
} catch (IOException e) {
// noop
}
}
Aggregations