use of org.commonjava.maven.atlas.ident.ref.SimpleTypeAndClassifier in project pom-manipulation-ext by release-engineering.
the class RESTCollector method recordDependencies.
/**
* Translate a given set of pvr:dependencies into ArtifactRefs.
* @param session the ManipulationSession
* @param project currently scanned project
* @param deps Set of ArtifactRef to store the results in.
* @param dependencies dependencies to examine
*/
private static void recordDependencies(ManipulationSession session, Project project, Set<ArtifactRef> deps, HashMap<ArtifactRef, Dependency> dependencies) throws ManipulationException {
if (dependencies == null) {
return;
}
for (ArtifactRef pvr : dependencies.keySet()) {
Dependency d = dependencies.get(pvr);
deps.add(new SimpleScopedArtifactRef(pvr, new SimpleTypeAndClassifier(d.getType(), d.getClassifier()), isEmpty(d.getScope()) ? DependencyScope.compile.realName() : PropertyResolver.resolveInheritedProperties(session, project, d.getScope())));
}
}
use of org.commonjava.maven.atlas.ident.ref.SimpleTypeAndClassifier in project pom-manipulation-ext by release-engineering.
the class RESTCollector method establishAllDependencies.
/**
* Scans a list of projects and accumulates all dependencies and returns them.
*
* @param session the ManipulationSession
* @param projects the projects to scan.
* @param activeProfiles which profiles to check
* @return an unsorted set of ArtifactRefs used.
* @throws ManipulationException if an error occurs
*/
public static Set<ArtifactRef> establishAllDependencies(ManipulationSession session, final List<Project> projects, Set<String> activeProfiles) throws ManipulationException {
Set<ArtifactRef> localDeps = new TreeSet<>();
Set<String> activeModules = new HashSet<>();
boolean scanAll = false;
if (activeProfiles != null && !activeProfiles.isEmpty()) {
for (final Project project : projects) {
if (project.isInheritanceRoot()) {
activeModules.addAll(project.getModel().getModules());
List<Profile> profiles = project.getModel().getProfiles();
if (profiles != null) {
for (Profile p : profiles) {
if (activeProfiles.contains(p.getId())) {
logger.debug("Adding modules for profile {}", p.getId());
activeModules.addAll(p.getModules());
}
}
}
}
}
logger.debug("Found {} active modules with {} active profiles.", activeModules, activeProfiles);
} else {
scanAll = true;
}
// Iterate over current project set and populate list of dependencies
for (final Project project : projects) {
if (project.isInheritanceRoot() || scanAll || activeModules.contains(project.getPom().getParentFile().getName())) {
if (project.getModelParent() != null) {
SimpleProjectVersionRef parent = new SimpleProjectVersionRef(project.getModelParent().getGroupId(), project.getModelParent().getArtifactId(), project.getModelParent().getVersion());
localDeps.add(new SimpleArtifactRef(parent, new SimpleTypeAndClassifier("pom", null)));
}
recordDependencies(session, project, localDeps, project.getResolvedManagedDependencies(session));
recordDependencies(session, project, localDeps, project.getResolvedDependencies(session));
recordPlugins(localDeps, project.getResolvedManagedPlugins(session));
recordPlugins(localDeps, project.getResolvedPlugins(session));
List<Profile> profiles = project.getModel().getProfiles();
if (profiles != null) {
for (Profile p : profiles) {
if (!scanAll && !activeProfiles.contains(p.getId())) {
continue;
}
recordDependencies(session, project, localDeps, project.getResolvedProfileManagedDependencies(session).get(p));
recordDependencies(session, project, localDeps, project.getResolvedProfileDependencies(session).get(p));
recordPlugins(localDeps, project.getResolvedProfileManagedPlugins(session).get(p));
recordPlugins(localDeps, project.getResolvedProfilePlugins(session).get(p));
}
}
}
}
return localDeps;
}
Aggregations