use of org.apache.maven.artifact.resolver.filter.ArtifactFilter in project maven-plugins by apache.
the class DefaultDependencyResolver method resolve.
private void resolve(Assembly assembly, AssemblerConfigurationSource configSource, Map<DependencySet, Set<Artifact>> result, DependencySet dependencySet, ResolutionManagementInfo info) throws DependencyResolutionException {
Set<Artifact> artifacts;
if (info.isResolutionRequired()) {
final List<ArtifactRepository> repos = aggregateRemoteArtifactRepositories(configSource.getRemoteRepositories(), info.getEnabledProjects());
artifacts = info.getArtifacts();
if (info.isResolvedTransitively()) {
getLogger().debug("Resolving project dependencies transitively.");
ArtifactFilter filter = new ArtifactIncludeFilterTransformer().transform(info.getScopeFilter());
artifacts = resolveTransitively(artifacts, repos, filter, configSource);
} else {
getLogger().debug("Resolving project dependencies ONLY. " + "Transitive dependencies WILL NOT be included in the results.");
artifacts = resolveNonTransitively(assembly, artifacts, configSource, repos);
}
} else {
artifacts = new HashSet<Artifact>();
}
result.put(dependencySet, artifacts);
}
use of org.apache.maven.artifact.resolver.filter.ArtifactFilter in project maven-plugins by apache.
the class PurgeLocalRepositoryMojo method purgeLocalRepository.
/**
* Purges the local repository for the dependencies in the given Maven project.
*
* @param project Maven project.
* @param resolvedArtifactsToPurge The artifacts that were already purged.
* @throws MojoFailureException in case of errors during the purge.
*/
private void purgeLocalRepository(MavenProject project, Set<Artifact> purgedArtifacts) throws MojoFailureException {
List<Dependency> dependencies = project.getDependencies();
TransformableFilter dependencyFilter = createPurgeArtifactsFilter(project, dependencies, purgedArtifacts);
Set<Artifact> resolvedArtifactsToPurge = getFilteredResolvedArtifacts(project, dependencies, dependencyFilter);
if (resolvedArtifactsToPurge.isEmpty()) {
getLog().info("No artifacts included for purge for project: " + project.getId());
return;
}
verbose("Purging dependencies for project: " + project.getId());
purgeArtifacts(resolvedArtifactsToPurge);
purgedArtifacts.addAll(resolvedArtifactsToPurge);
if (reResolve) {
ArtifactFilter artifactFilter = dependencyFilter.transform(new ArtifactIncludeFilterTransformer());
try {
reResolveArtifacts(project, resolvedArtifactsToPurge, artifactFilter);
} catch (ArtifactResolutionException e) {
String failureMessage = "Failed to refresh project dependencies for: " + project.getId();
MojoFailureException failure = new MojoFailureException(failureMessage);
failure.initCause(e);
throw failure;
} catch (ArtifactNotFoundException e) {
String failureMessage = "Failed to refresh project dependencies for: " + project.getId();
MojoFailureException failure = new MojoFailureException(failureMessage);
failure.initCause(e);
throw failure;
}
}
}
use of org.apache.maven.artifact.resolver.filter.ArtifactFilter in project fabric8 by fabric8io.
the class BuildMojo method collectClassPath.
private ArrayList<Artifact> collectClassPath() throws DependencyGraphBuilderException {
ArtifactFilter filter = new ScopeArtifactFilter(scope);
DependencyNode rootNode = dependencyGraphBuilder.buildDependencyGraph(project, filter);
final ArrayList<Artifact> artifacts = new ArrayList<>();
rootNode.accept(new DependencyNodeVisitor() {
@Override
public boolean visit(DependencyNode dependencyNode) {
artifacts.add(dependencyNode.getArtifact());
return true;
}
@Override
public boolean endVisit(DependencyNode dependencyNode) {
return true;
}
});
return artifacts;
}
use of org.apache.maven.artifact.resolver.filter.ArtifactFilter in project wso2-synapse by wso2.
the class AbstractXarMojo method buildSynapseRuntimeArtifactFilter.
/**
* Build a filter that excludes all artifacts that are provided by Synapse at runtime.
*
* @return
* @throws MojoExecutionException
*/
private ArtifactFilter buildSynapseRuntimeArtifactFilter() throws MojoExecutionException {
final Map<String, Artifact> artifacts = new HashMap<String, Artifact>();
for (Artifact artifact : getSynapseRuntimeArtifacts()) {
artifacts.put(artifact.getDependencyConflictId(), artifact);
}
final Set<String> defaultExclusionSet = new HashSet<String>(Arrays.asList(defaultRuntimeExcludes));
return new ArtifactFilter() {
public boolean include(Artifact artifact) {
Artifact runtimeArtifact = artifacts.get(artifact.getDependencyConflictId());
if (runtimeArtifact == null) {
return !defaultExclusionSet.contains(artifact.getDependencyConflictId());
} else {
if (!runtimeArtifact.getVersion().equals(artifact.getVersion())) {
getLog().warn("Possible runtime version conflict for " + artifact.getArtifactId() + ": XAR depends on " + artifact.getVersion() + ", Synapse runtime provides " + runtimeArtifact.getVersion());
}
return false;
}
}
};
}
Aggregations