Search in sources :

Example 1 with GroupVersionAlignment

use of org.apache.maven.plugins.assembly.repository.model.GroupVersionAlignment 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
    }
}
Also used : DependencyResolverException(org.apache.maven.shared.dependencies.resolve.DependencyResolverException) Dependency(org.apache.maven.model.Dependency) IOException(java.io.IOException) Logger(org.codehaus.plexus.logging.Logger) ArtifactResult(org.apache.maven.shared.artifact.resolve.ArtifactResult) ProjectBuildingRequest(org.apache.maven.project.ProjectBuildingRequest) ScopeArtifactFilter(org.apache.maven.shared.artifact.filter.ScopeArtifactFilter) PatternExcludesArtifactFilter(org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter) AndArtifactFilter(org.apache.maven.artifact.resolver.filter.AndArtifactFilter) ArtifactFilter(org.apache.maven.artifact.resolver.filter.ArtifactFilter) PatternIncludesArtifactFilter(org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter) MavenProject(org.apache.maven.project.MavenProject) GroupVersionAlignment(org.apache.maven.plugins.assembly.repository.model.GroupVersionAlignment) File(java.io.File)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 AndArtifactFilter (org.apache.maven.artifact.resolver.filter.AndArtifactFilter)1 ArtifactFilter (org.apache.maven.artifact.resolver.filter.ArtifactFilter)1 Dependency (org.apache.maven.model.Dependency)1 GroupVersionAlignment (org.apache.maven.plugins.assembly.repository.model.GroupVersionAlignment)1 MavenProject (org.apache.maven.project.MavenProject)1 ProjectBuildingRequest (org.apache.maven.project.ProjectBuildingRequest)1 PatternExcludesArtifactFilter (org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter)1 PatternIncludesArtifactFilter (org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter)1 ScopeArtifactFilter (org.apache.maven.shared.artifact.filter.ScopeArtifactFilter)1 ArtifactResult (org.apache.maven.shared.artifact.resolve.ArtifactResult)1 DependencyResolverException (org.apache.maven.shared.dependencies.resolve.DependencyResolverException)1 Logger (org.codehaus.plexus.logging.Logger)1