use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class DependencyGraphParserTest method testOptionalScope.
@Test
public void testOptionalScope() throws IOException {
String def = "gid:aid:jar:1";
DependencyNode node = parser.parseLiteral(def);
assertNotNull(node);
assertEquals(0, node.getChildren().size());
Dependency dependency = node.getDependency();
assertNotNull(dependency);
assertEquals("", dependency.getScope());
}
use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class DependencyGraphParserTest method assertNodeProperties.
private void assertNodeProperties(DependencyNode node, String suffix) {
assertNotNull(node);
Dependency dependency = node.getDependency();
assertNotNull(dependency);
if (!"".equals(dependency.getScope())) {
assertEquals("scope" + suffix, dependency.getScope());
}
Artifact artifact = dependency.getArtifact();
assertNotNull(artifact);
assertEquals("gid" + suffix, artifact.getGroupId());
assertEquals("aid" + suffix, artifact.getArtifactId());
assertEquals("ext" + suffix, artifact.getExtension());
assertEquals("ver" + suffix, artifact.getVersion());
}
use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class ConflictMarker method mark.
private Map<DependencyNode, Object> mark(Collection<DependencyNode> nodes, Map<Object, ConflictGroup> groups) {
Map<DependencyNode, Object> conflictIds = new IdentityHashMap<DependencyNode, Object>(nodes.size() + 1);
for (DependencyNode node : nodes) {
Dependency dependency = node.getDependency();
if (dependency != null) {
Object key = toKey(dependency.getArtifact());
conflictIds.put(node, groups.get(key).keys);
}
}
return conflictIds;
}
use of org.sonatype.aether.graph.Dependency in project sonatype-aether by sonatype.
the class JavaDependencyContextRefiner method getClasspathScope.
private String getClasspathScope(DependencyNode node) {
Dependency dependency = node.getDependency();
if (dependency == null) {
return null;
}
String scope = dependency.getScope();
if (JavaScopes.COMPILE.equals(scope) || JavaScopes.SYSTEM.equals(scope) || JavaScopes.PROVIDED.equals(scope)) {
return JavaScopes.COMPILE;
} else if (JavaScopes.RUNTIME.equals(scope)) {
return JavaScopes.RUNTIME;
} else if (JavaScopes.TEST.equals(scope)) {
return JavaScopes.TEST;
}
return null;
}
use of org.sonatype.aether.graph.Dependency in project intellij-community by JetBrains.
the class Maven30ServerEmbedderImpl method doResolveProject.
@NotNull
public Collection<MavenExecutionResult> doResolveProject(@NotNull final Collection<File> files, @NotNull final List<String> activeProfiles, @NotNull final List<String> inactiveProfiles, final List<ResolutionListener> listeners) throws RemoteException {
final File file = files.size() == 1 ? files.iterator().next() : null;
final MavenExecutionRequest request = createRequest(file, activeProfiles, inactiveProfiles, Collections.<String>emptyList());
request.setUpdateSnapshots(myAlwaysUpdateSnapshots);
final Collection<MavenExecutionResult> executionResults = ContainerUtil.newArrayList();
executeWithMavenSession(request, new Runnable() {
@Override
public void run() {
try {
RepositorySystemSession repositorySession = getComponent(LegacySupport.class).getRepositorySession();
if (repositorySession instanceof DefaultRepositorySystemSession) {
((DefaultRepositorySystemSession) repositorySession).setTransferListener(new Maven30TransferListenerAdapter(myCurrentIndicator));
if (myWorkspaceMap != null) {
((DefaultRepositorySystemSession) repositorySession).setWorkspaceReader(new Maven30WorkspaceReader(myWorkspaceMap));
}
}
List<ProjectBuildingResult> buildingResults = getProjectBuildingResults(request, files);
for (ProjectBuildingResult buildingResult : buildingResults) {
MavenProject project = buildingResult.getProject();
if (project == null) {
List<Exception> exceptions = new ArrayList<Exception>();
for (ModelProblem problem : buildingResult.getProblems()) {
exceptions.add(problem.getException());
}
MavenExecutionResult mavenExecutionResult = new MavenExecutionResult(buildingResult.getPomFile(), exceptions);
executionResults.add(mavenExecutionResult);
continue;
}
List<Exception> exceptions = new ArrayList<Exception>();
loadExtensions(project, exceptions);
//Artifact projectArtifact = project.getArtifact();
//Map managedVersions = project.getManagedVersionMap();
//ArtifactMetadataSource metadataSource = getComponent(ArtifactMetadataSource.class);
project.setDependencyArtifacts(project.createArtifacts(getComponent(ArtifactFactory.class), null, null));
if (USE_MVN2_COMPATIBLE_DEPENDENCY_RESOLVING) {
addMvn2CompatResults(project, exceptions, listeners, myLocalRepository, executionResults);
} else {
final DependencyResolutionResult dependencyResolutionResult = resolveDependencies(project, repositorySession);
final List<Dependency> dependencies = dependencyResolutionResult.getDependencies();
Set<Artifact> artifacts = new LinkedHashSet<Artifact>(dependencies.size());
for (Dependency dependency : dependencies) {
final Artifact artifact = RepositoryUtils.toArtifact(dependency.getArtifact());
artifact.setScope(dependency.getScope());
artifact.setOptional(dependency.isOptional());
artifacts.add(artifact);
resolveAsModule(artifact);
}
project.setArtifacts(artifacts);
executionResults.add(new MavenExecutionResult(project, dependencyResolutionResult, exceptions));
}
}
} catch (Exception e) {
executionResults.add(handleException(e));
}
}
});
return executionResults;
}
Aggregations