use of org.apache.maven.artifact.repository.ArtifactRepository in project maven-plugins by apache.
the class DefaultDependencyResolver method aggregateRemoteArtifactRepositories.
List<ArtifactRepository> aggregateRemoteArtifactRepositories(final List<ArtifactRepository> remoteRepositories, final Set<MavenProject> projects) {
final List<List<ArtifactRepository>> repoLists = new ArrayList<List<ArtifactRepository>>();
repoLists.add(remoteRepositories);
for (final MavenProject project : projects) {
repoLists.add(project.getRemoteArtifactRepositories());
}
final List<ArtifactRepository> remoteRepos = new ArrayList<ArtifactRepository>();
final Set<String> encounteredUrls = new HashSet<String>();
for (final List<ArtifactRepository> repositoryList : repoLists) {
if ((repositoryList != null) && !repositoryList.isEmpty()) {
for (final ArtifactRepository repo : repositoryList) {
if (!encounteredUrls.contains(repo.getUrl())) {
remoteRepos.add(repo);
encounteredUrls.add(repo.getUrl());
}
}
}
}
return remoteRepos;
}
use of org.apache.maven.artifact.repository.ArtifactRepository 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.repository.ArtifactRepository in project maven-plugins by apache.
the class MavenProject4CopyConstructor method initializeParentFields.
// to prevent the MavenProject copy constructor from blowing up
private void initializeParentFields() {
// the pom should be located in the isolated dummy root
super.setFile(new File(getBasedir(), "pom.xml"));
super.setDependencyArtifacts(new HashSet<Artifact>());
super.setArtifacts(new HashSet<Artifact>());
super.setExtensionArtifacts(new HashSet<Artifact>());
super.setRemoteArtifactRepositories(new LinkedList<ArtifactRepository>());
super.setPluginArtifactRepositories(new LinkedList<ArtifactRepository>());
super.setCollectedProjects(new LinkedList<MavenProject>());
super.setActiveProfiles(new LinkedList<Profile>());
super.setOriginalModel(null);
super.setExecutionProject(this);
super.setBuild(getBuild());
}
use of org.apache.maven.artifact.repository.ArtifactRepository in project sling by apache.
the class BundleInstallFileMojo method resolveBundleFileFromArtifact.
@SuppressWarnings({ "rawtypes", "unchecked", "deprecation" })
private String resolveBundleFileFromArtifact() throws MojoExecutionException {
if (artifactId == null && artifact == null) {
return null;
}
if (artifactId == null) {
String[] tokens = StringUtils.split(artifact, ":");
if (tokens.length != 3 && tokens.length != 4 && tokens.length != 5) {
throw new MojoExecutionException("Invalid artifact, you must specify " + "groupId:artifactId:version[:packaging[:classifier]] " + artifact);
}
groupId = tokens[0];
artifactId = tokens[1];
version = tokens[2];
if (tokens.length >= 4)
packaging = tokens[3];
if (tokens.length == 5)
classifier = tokens[4];
}
Artifact packageArtifact = artifactFactory.createArtifactWithClassifier(groupId, artifactId, version, packaging, classifier);
if (pomRemoteRepositories == null) {
pomRemoteRepositories = new ArrayList();
}
List repoList = new ArrayList(pomRemoteRepositories);
if (repositoryUrl != null) {
ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy(true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
ArtifactRepository remoteRepo = artifactRepositoryFactory.createArtifactRepository(repositoryId, repositoryUrl, repositoryLayout, policy, policy);
repoList.add(remoteRepo);
}
try {
artifactResolver.resolve(packageArtifact, repoList, localRepository);
getLog().info("Resolved artifact to " + packageArtifact.getFile().getAbsolutePath());
} catch (AbstractArtifactResolutionException e) {
throw new MojoExecutionException("Couldn't download artifact: " + e.getMessage(), e);
}
return packageArtifact.getFile().getAbsolutePath();
}
use of org.apache.maven.artifact.repository.ArtifactRepository in project bnd by bndtools.
the class DependencyResolver method resolve.
public Map<File, ArtifactResult> resolve() throws MojoExecutionException {
if (resolvedDependencies != null) {
return resolvedDependencies;
}
DependencyResolutionRequest request = new DefaultDependencyResolutionRequest(project, session);
request.setResolutionFilter(new DependencyFilter() {
@Override
public boolean accept(DependencyNode node, List<DependencyNode> parents) {
if (node.getDependency() != null) {
return scopes.contains(node.getDependency().getScope());
}
return false;
}
});
DependencyResolutionResult result;
try {
result = resolver.resolve(request);
} catch (DependencyResolutionException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
Map<File, ArtifactResult> dependencies = new HashMap<>();
DependencyNode dependencyGraph = result.getDependencyGraph();
if (dependencyGraph != null && !dependencyGraph.getChildren().isEmpty()) {
List<RemoteRepository> remoteRepositories = new ArrayList<>(project.getRemoteProjectRepositories());
ArtifactRepository deployRepo = project.getDistributionManagementArtifactRepository();
if (deployRepo != null) {
remoteRepositories.add(RepositoryUtils.toRepo(deployRepo));
}
discoverArtifacts(dependencies, dependencyGraph.getChildren(), project.getArtifact().getId(), remoteRepositories);
}
return resolvedDependencies = dependencies;
}
Aggregations